Web-server – Apache server-status returning 404, then redirecting to the WordPress install

.htaccessapache-2.2web-server

I'm trying to get Munin's various Apachie plugins to work on my web server, but I'm hitting issues. Upon asking Munin to check available plugins, two of the three Apache plugins return an error saying that

apache server-status cannot be found

I've got mod_status turned on etc, and as far as I know, everything's set up correctly.

I've tried opening localhost/server-status using Lynx, at which point I get a 404 error and my WordPress error page is shown (the one you get when you try to access a page that doesn't exist.)

Now presumably this is something to do with how I have Apache serving a WordPress install etc. The web site lives in /var/www/wordpress, with the index.php file one level up and the .htaccess file amended as per the WordPress instructions. It works fine, but I've a niggling feeling that when Munin/Lynx tries to load localhost/server-status, it's looking for it in /var/www/.

So, how do I tell Apache where to actually look when requesting server-status?


Here's my httpd.conf file.

ServerName localhost



<VirtualHost *:80>
ServerName oliverhaslam.com
ServerAlias oliverhaslam.com
DocumentRoot /var/www/wordpress/
</VirtualHost>


<VirtualHost *:80>
ServerName ojhaslam.co.uk
ServerAlias ojhaslam.co.uk
DocumentRoot /var/sites/photo365/
</VirtualHost>

<VirtualHost *:80>
ServerName www.ojhaslam.co.uk
ServerAlias www.ojhaslam.co.uk
RedirectMatch permanent /(.*) http://ojhaslam.co.uk/$1
DocumentRoot /var/sites/photo365/
</VirtualHost>

<Location /server-status>
        SetHandler server-status
        Order deny,allow
        Allow from  all
</Location>

If I remove the last part, I get a 'forbidden' error instead of the error outlined above.


Appears the issue is my .htaccess file. Removing that means the server-status works, but obviously WordPress links don't. Here's the file:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

#Next two don't fix the issue.    
#RewriteCond %{REQUEST_URI} !=/server-status
#RewriteRule ^(server-info|server-status) - [L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Best Answer

Wordpress's .htaccess file sends all non-existing files and directories to be processed by Wordpress. Try excluding the server status urls too.

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/server-status
RewriteRule . /index.php [L]
Related Topic