Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm having an issue implementing 301 Redirects via .htaccess file on an Apache server.

I can enable the 'Redirect 301' statements in the .htaccess file and they will appear to work for a few minutes, but soon after the server starts returning "too many automatic redirects" errors and the site becomes unavailable.

Clearly, I have a loop somewhere in the code, but I can't see it. Would someone be able to point it out?

Also, should I be using 'RedirectMatch' instead of 'Redirect'?

Here is the content of the .htaccess file:

ErrorDocument 404 http://www.example.com/404.html
RewriteEngine On
RewriteRule (wooden_house|straw_house|brick_house_(One|Two|Three)Piggy)\.html$ /$1.php  

# //Rewrite to www
Options +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^example.com [nc]
RewriteRule ^(.*)$ http://www.example.com/$1 [r=301,nc]

RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]

# //301 Redirect Old File
Redirect 301 /index.php http://www.example.com
Redirect 301 /index.shtml http://www.example.com
Redirect 301 /index.pl http://www.example.com
Redirect 301 /default.htm http://www.example.com
share|improve this question
    
What URL are you being sent to by the infinite redirects? –  Shane Madden Jul 19 '12 at 3:05
    
No URL... the browser either displays a blank screen or a message from the browser stating that the requested page cannot be displayed because of too many redirects. I'm wondering if there's a setting on the server that is causing the redirect issue because I just don't see where it's happening in the code I have in the .htaccess file. –  n00b-user Jul 23 '12 at 13:48
    
Some browsers will tell you, some will not, but there is a Location header being sent in responses to your browser. It would be helpful to have that information - can you gather it either using curl -v or a packet capture tool like wireshark? Additionally, what kind of content are you serving - just PHP code? What's an example URL that you're attempting to load when the problem occurs? –  Shane Madden Jul 23 '12 at 15:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.