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 getting a very odd redirect issue on my server. URL's without a trailing slash are being redirected to a URL with a trailing slash. The problem is that URL then redirects infinitely to itself.

e.g.:

http://new.whitehardt.com/services/commercials/ - works fine

but

http://new.whitehardt.com/services/commercials - redirects to
http://new.whitehardt.com/services/commercials/ which in turn causes a redirect loop

I've checked .htaccess which only contains the following:

DirectoryIndex index.php

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

I've been searching for 2 days for a solution to this issue. Any help would be greatly appreciated!

share|improve this question
    
Can you turn on a RewriteLog location and set RewriteLogLevel 9? Doesn't look like Apache should be redirecting, based on the config you've provided. –  Shane Madden Mar 14 '12 at 15:52
add comment

1 Answer

Interesting that it's a 301 redirect and not a 302. You might be able to find the offending line with a bit of grep magic.

grep -Eir "R=301|redirect permenent" /etc/apache2/

Substitute /etc/httpd/ if you're on a RedHat-derived distro.

Failing that, it might be part of one of the PHP files. A similar grep for "header" in your DocumentRoot might find it.

share|improve this answer
    
Thanks for the quick response, forgive my ignorance but where would I run that code for grep? (add it .htaccess, shell, etc?) –  Jonathan Mar 14 '12 at 16:17
    
That's a shell command. You'll want to use SSH to connect to your server and then run that. If your local machine is Windows, PuTTY seems to be the default choice of SSH client. –  Ladadadada Mar 14 '12 at 16:20
    
Ok that's what I thought but just wanted to be sure. Just ran it and it returned nothing. –  Jonathan Mar 14 '12 at 16:25
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.