Welcome to WebmasterWorld Guest from

Forum Moderators: phranque

Message Too Old, No Replies

htaccess redirect



7:47 pm on Jan 14, 2006 (gmt 0)

5+ Year Member

Hi All new here.

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


[edited by: jatar_k at 6:01 am (utc) on Jan. 15, 2006]
[edit reason] examplified url [/edit]


3:26 am on Jan 15, 2006 (gmt 0)

10+ Year Member

That should be fairly easy:

Use this code:

RewriteEngine on

RewriteCond %{HTTP_HOST}!^www\.example\.com\.au$
RewriteRule ^(.*)$ http://www.example.com.au/$1 [L,R=301]

Hope that helps.

[edited by: jatar_k at 6:01 am (utc) on Jan. 15, 2006]
[edit reason] examplified url [/edit]


5:31 am on Jan 15, 2006 (gmt 0)

5+ Year Member

No, sorry that doesn't work. I get an internal server error message. I should also mention that I am using Frontpage 2003, if that matters.



7:41 am on Jan 15, 2006 (gmt 0)

WebmasterWorld Senior Member keyplyr is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

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}.


6:31 pm on Jan 15, 2006 (gmt 0)

5+ Year Member

Thanks that works



Featured Threads

Hot Threads This Week

Hot Threads This Month