Forum Moderators: phranque
I have read as follows
"Also, I would use a 301 redirect or rewrite so that your root page doesn't appear twice. For example, if you select [yourdomain.com...] as your root page, then if a spider tries to fetch [yourdomain.com...] (without the www), your web server should do a permanent (301) redirect to your root page at [yourdomain.com...] "
I have attempted this and screwed up several times. My site has more than 250 pages and I would like to have the code that I will add to my .htaccess file that will redirect all pages from http://example.com.au to http://www.example.com.au
Thanks in advance
Des
[edited by: jatar_k at 6:01 am (utc) on Jan. 15, 2006]
[edit reason] examplified url [/edit]
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
Note: This is essentially the same code posted by Spiekerooger. This forum removes spaces sometimes. If you're cut'n pasting, make sure there's a space after occurances of {HTTP_HOST}.