useful .htaccess hack for redirecting all requests to the same URL
by Evil Overlord in
Web Design/WP
during rush hour on
January 16th, 2006:
2 years, 7 months ago
Not terribly exciting, but I lost this bit of code once, so I’m making an archive.
This is useful if you want to redirect http://tylerwillis.com to http://www.tylerwillis.com without going through any needless meta refreshing or webpage crap. Stick this in your .htaccess and all requests will automatically be forwarded instantaneously.
Why?
Better to have just one URL than two for pagerank and adsense tracking. Also makes things nice and uniform. For the anal, I guess.
In any case, ripped straight from my file:
# BEGIN Redirect to www
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^tylerwillis\.com [NC]
RewriteRule ^/*(.*) http://www.tylerwillis.com/$1 [L,R=301]
# END Redirect to www
Simply change tylerwillis with whatever domain you need.
Source is a thread over at webhosting talk.

One Response to 'useful .htaccess hack for redirecting all requests to the same URL'
alert(’this is a test’);
[Quote]