homepage Welcome to WebmasterWorld Guest from 54.227.67.210
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / WebmasterWorld / Webmaster General
Forum Library, Charter, Moderators: phranque & physics

Webmaster General Forum

    
htaccess redirect
dasher1




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

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

Des

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

 

Spiekerooger




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

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]

dasher1




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

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.

Des

keyplyr




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

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

dasher1




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

Thanks that works

Des

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / Webmaster General
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved