Page 1 of 1

.HTACCESS 301 Redirect

Posted: Thu Jul 10, 2008 5:20 am
by malcolmboston
I have the following code in my .htaccess file

Code: Select all

 
redirect 301 /index.php http://www.mysite.co.uk/
 
the purpose of this is anyone visiting http://www.mysite.co.uk/index.php will automatically be redirected to http://www.mysite.co.uk/

something is obviously wrong however as firefox gives me the following message
Firefox wrote: Redirect Loop

Redirection limit for this URL exceeded. Unable to load the requested page. This may be caused by cookies that are blocked.

The browser has stopped trying to retrieve the requested item. The site is

redirecting the request in a way that will never complete.

* Have you disabled or blocked cookies required by this site?
* NOTE: If accepting the site's cookies does not resolve the problem, it is probably a server configuration
issue and not your computer.
Ive done a search and cant seem to find whats wrong with my line of code, can someone point me in the right direction?

Cheers, Mal

Re: .HTACCESS 301 Redirect

Posted: Thu Jul 10, 2008 7:53 am
by matthijs
I think you should change the rule to

Code: Select all

 
Redirect permanent /oldpage.html http://www.newsite.com/new-page/
 
At least, that's what I did when I had to do the same thing.

Also, do you have any other rules in the htaccess file? Sometimes it's the combination of certain rules which cause the loop.

Re: .HTACCESS 301 Redirect

Posted: Thu Jul 10, 2008 8:33 am
by matthijs
Mal, are you sure that rule is actually needed? Normally apache is configured in such a way that yoursite.com/ automatically calls the index.php or index.html pages. Redirecting index.php to the root yoursite.com/ will therefore cause an infinite loop.

So my guess is that you should not write that rule.

Re: .HTACCESS 301 Redirect

Posted: Thu Jul 10, 2008 8:44 am
by JayBird
Perhaps it is a server setting becuase i have just tried it on my server and it works just as expected.

Re: .HTACCESS 301 Redirect

Posted: Thu Jul 10, 2008 9:44 am
by malcolmboston
thanks for that Mark, ill look into it.