One thing that I constantly have to do with sites is add, for SEO purposes, a redirect of non-www to www. The reason being, Google sees michaelbarton.name and www.michaelbarton.name as two different sites and I’d get penalized for having duplicate content should someone out there link to my site using one or the other.

The solution being, choose which one you want to have redirect – non-www to www or www to non-www. The choice is yours. It’s really just a personal preference for me to use www in front of my domain.

The Solution: non-www to www

1
2
3
4
5
6
<ifmodule mod_rewrite.c>
RewriteEngine On
# Redirect non-www to www
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
</ifmodule>


CONTINUE READING


This is an oldie but a goody. In web development there comes a time when you need to force a download when someone clicks on a link, without telling them to “right click save as…” In the past this was always a problem. Now thanks to Google, you can type in keywords and find a nice, lovely blog post like this one and figure it out. And of course you’re not going to tell anyone because you want to look like a Rock Star. So you’re going to say “ain’t nothing but a thang.”

And before you do that, here’s how you’re going to save the day and prompt a “Save As” to the user so he/she can download his/her file:

1
2
# Put all your extensions after the word stream
AddType application/octet-stream .doc .mov .avi .pdf .xls .mp4 .xlsx .docm


CONTINUE READING