Forum Moderators: mack

Message Too Old, No Replies

301 redirect error

The page isn't redirecting properly

         

reprint

10:43 pm on Mar 1, 2007 (gmt 0)

10+ Year Member



I am trying to do a 301 redirect from the www to the non-www version of my website. I included Redirect 301 / [mywebsite.com...] in the htaccess file and i get the following error on any webpage on my site i try:
The page isn't redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

* This problem can sometimes be caused by disabling or refusing to accept
cookies.

Anyone know what i am doing wrong?

thanks


coopster

11:10 pm on Mar 1, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You are sending the server into an infinite loop. You cannot use a Redirect [httpd.apache.org] directive like that. You could either setup a <VirtualHost> [httpd.apache.org] container for the
www.example.com
version of your site or you could use mod_rewrite [httpd.apache.org] if you don't have access to the Apache configuration.

reprint

11:33 pm on Mar 1, 2007 (gmt 0)

10+ Year Member



Appreciate the quick response. When I did a search on the forums here, that was what people seemed to suggest. I tried following the links you provided but I am not a programmer and have no idea how to make heads or tails out of the info in the links. This redirect much be a common thing. Is there a snippet of code lying around somewhere to do this that i can paste into the htaccess file?

Out of curiosity why does that command send the website into a loop?

thanks

LunaC

11:48 pm on Mar 1, 2007 (gmt 0)

10+ Year Member



Here's what I use for a site I have without the www:

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

The code you have sends *anything* (including [mywebsite.com...] to [mywebsite.com,...] it isn't saying to check for the www, just to 301 all.

reprint

12:06 am on Mar 2, 2007 (gmt 0)

10+ Year Member



Thanks LunC. I get what you mean about my code being a loop. I tried the code you gave me subbing in my site where you have example but it doesnt do anything. Maybe i will have to try taking some time to learn to code this.
thanks though