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.


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


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]

# END WordPress

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

  • 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

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.

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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