httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Ulrich <>
Subject [users@httpd] Rewrite rules in .htaccess: Internal redirect loop
Date Fri, 15 Apr 2016 22:48:25 GMT
Hi everyone, 

I'm trying to track down a problem with rewrite rules. I have set up a WordPress multisite
installation. In the root directory of this installation, there's a .htaccess file which contains
some rewrite rules. I've copy&pasted the content of the .htaccess file to the bottom of
this email.

The problem is: When someone requests a non-existent file in /wp-content/ or one of its subfolders,
like, or
then they end up with an error 500 and the following message appears in my error.log: "Request
exceeded the limit of 10 internal redirects due to probable configuration error."

Expected behaviour would be that Apache serves an error 404 page.

This problem has been reported in the WordPress bugtracker, but there's some confusion on
what the ideal fix should look like:

It has been suggested in the discussion on that ticket that there's a problem with this directive:
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]

This rewrite rule is supposed to rewrite request URIs like "/subdir/wp-content/something"
to "/wp-content/something". Moreover, I think that it's supposed to prevent request URIs like
"/wp-content/something" from being rewritten to "index.php" by the last rewrite rule. Expected
behaviour would be that such requests are served by Apache without invoking WordPress. 

I understand that request URIs like /wp-content/something match the pattern of the above rewrite
rule. I don't understand, though, why the redirect loop occurs. Shouldn't this rewrite rule
leave URIs like /wp-content/something unchanged (because the substituted URI is the same as
the original URI)? And shouldn't Apache stop the rewriting process if a request URI hasn't
been changed during the latest loop through .htaccess? 

This is the content of my .htaccess file, which is located in the root directory of my WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

# don't rewrite if request URI points to existing file or folder
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Is there something wrong with these?
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message