Why do I get a 404 Not Found when trying to get server status?

This can also happen when you have a .htaccess file in the document root and that file contains a RewriteRule, as is common with CMS pretty URLs.

The explanation for this behaviour is as follows. The <Location> directives act first, but the handler is not called at this stage. So then the RewriteRule sets a handler, eg to run a PHP script, so SetHandler has no effect in the end.

If this is the cause, find the RewriteRule that is causing the problem(*), and add before it:

RewriteCond %{REQUEST_URI} !=/server-status

This excludes the server-status URI from the RewriteRule in the same way that existing static files may be excluded. Of course what you use in place of /server-status must exactly match the Location chosen, which in the question is instead /status. (Tested on Apache 2.2.22 and Apache 2.4)

Addendum: also note that you can get a 403 trying to read the server-status if the DocumentRoot is not readable by the apache process at all, again because the server-status handler doesn't have a chance to work.

Addendum 2: if the .htaccess for the Apache default site is frequently overwritten, and the /server-status URL is necessary for eg Munin to work, then creating a <VirtualHost 127.0.0.1:80> stanza including the server-status handler may be administratively simplest.

Addendum 3(*): the RewriteRule that is causing the problem is potentially anything that matches the string /server-status. This may be identifiable because the first parameter will match anything, for example beginning RewriteRule . where the . will match any character, or ^(.*), or otherwise is catching the URI such as .*\bstatus$. You may also identify it because it deliberately excludes existing files with !-f.

For example, if WordPress is the main site and you want /server-status to appear on it, and for some reason Addendum 2 above is not applicable, you may want to insert an extra RewriteCond as follows:

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

However, it probably does no harm before any RewriteRule.


My guess would be that you didn't load the status module - Can you confirm it ?


Because you've misconfigured something. What do your logs say about the cause of the 404? My first guess would be that ip:port isn't a valid vhost (or at least not valid for the vhost you've put the <Location /status> in, anyway), and it's probably dropping back to the default vhost. The error logs will make mention of irrational paths you didn't configure if that's the case. Other error log messages will mean different things, which is why it's so important to check them.