Wordpress mod_rewrite rules taking over mod_status

While working on setting up a monitoring solution for a big wordpress installation, I realized that the server-status url was not working as expected even if mod_status was configured correctly:

ExtendedStatus On
	<Location /server-status>
	SetHandler server-status
	Order deny,allow
	Deny from all
	Allow from some_ips
</Location>

The .htaccess wordpress rules were taking over this and the server-status url was returning a page not found error from within wordpress. This was happening because of the way how the rewrite rules are setup to handle all the permalinks on the site, and for any non-existing file send it to index.php:

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

This works fine with any aliases defined in apache, but the mod_status handler was going to the rewrite rules first, hence the problem. This is not a wordpress problem, and should happen with any other application (like zend framework is one other example that comes to my mind right now) that uses the same type of catch-all rewrite rules to handle all the urls inside the application. The solution in this case is to specifically add a rewrite rule to not have the server-status url processed and sent to the default rule:

RewriteCond %{REQUEST_URI} !=/server-status

and the wordpress rewrite rules should look like this:

# BEGIN WordPress
<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteBase /
	RewriteCond %{REQUEST_URI} !=/server-status
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule . /index.php [L]
</IfModule>
# END WordPress
comments powered by Disqus