23

Jul

Filed in Code, JavaScript |

Since everything on page one of google isn’t, well, perfect, here’s a fully working example where you don’t need to type in your silly domain name.

# redirect all non-www traffic
RewriteCond %{HTTP_HOST} ^([a-zA-Z0-9\-]*)\.com$
RewriteRule ^.*$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

For the unknowing, this code uses mod_rewrite.

blog comments powered by Disqus