9

I have this virtual host setup as the first in a list of virtual hosts. It is

<VirtualHost localhost:80>
ServerName localhost
DocumentRoot "/www/drupal5"

<Location /server-status>
    SetHandler server-status
    Order Deny,Allow
    Allow from localhost
</Location>
</VirtualHost>

The rest of the virtual hosts are below and expressed as *:80.

When I include the DocumentRoot in this virtual host, requests on the server to http://localhost/server-status always hit /index.php through rewrite rules in /www/drupal5/.htaccess. If I remove the DocumentRoot declaration, /server-status requests work fine, but then the site isn't available at all at http://localhost/.

How can I get http://localhost/server-status to work as well as the site to load at http://localhost/ ?

  • Can you post the contents of `/www/drupal5/.htaccess`? Hopefully, it is possible to modify the rewrite rules so that requests for /server-status are not rewritten. – Steven Monday Oct 23 '10 at 01:19
  • The clarification I think I need is: is it possible for mod_rewrite to overwrite what happens to a /server-status path even though it's been handled in the –  Oct 23 '10 at 01:29

3 Answers3

15

Found the solution when I googled 'server-status mod_rewrite'. Coincidentally it was answered in a drupal forum: http://drupal.org/node/52511

Adding RewriteCond %{REQUEST_URI} !=/server-status to the rewrite rule for redirecting all traffic to /index.php fixed it.

Very confusing that mod_rewrite can rewrite a uri that's already set a handler.

5

Just add a blank vhost entry to the top of the vhost configuration file e.g.

<VirtualHost *:80>
</VirtualHost>
Nomad77
  • 59
  • 1
  • 2
  • 2
    How would it solve the original question? – Pothi Kalimuthu Oct 09 '13 at 07:21
  • 1
    Apache is defaulting to the OPs first named vhost, their Drupal install, instead of going to the server-status page. An empty vhost will stop the processing for /server-status from being sent to Drupal and allow the status page to load – xref Sep 11 '14 at 17:09
  • But won't this new "first" VirtualHost catch *all* traffic and thus prevent all normal (non-server-status) traffic from flowing through to the Drupal application VirtualHost? – AMF Sep 15 '21 at 19:15
3

If you're using Apache 2.3 or higher, you should also be able to use the END flag in your VirtualHost entry, to save having to modify the .htaccess files.

RewriteCond %{REQUEST_URI} /server-status
RewriteRule ^ - [END]

Should prevent the subsequent rules from rewriting things.

cincodenada
  • 192
  • 6