Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have an Apache2 server with various virtual servers running. For SEO purposes, anything that does not match www.mydomain.com is automatically redirected to www.mydomain.com.

RewriteCond %{HTTP_HOST} !^www\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com$1 [R=301,L]

This is working fine but I want to monitor status of the apache server by calling http://localhost/server-status?auto

The problem is that this is redirecting to http://www.mydomain.com/server-status which is not a valid URL. What additional redirect can I add to avoid this problem? Or is there some other way this can be tackled?

share|improve this question

1 Answer 1

Try:

RewriteCond %{REQUEST_URI} !=/server-status
RewriteCond %{HTTP_HOST} !^www\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com$1 [R=301,L]
share|improve this answer
    
Thank you for the answer. But this didn't help me. The issue was a bit of complication with DocumentRoot pointing to /var/www/mydomain, access rights for /server-status location (Allow from 127.0.0.1 instead of Allow from localhost) and then adding a special virtual host for localhost. –  sayeed Feb 27 '11 at 13:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.