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 am trying to write a redirect rule that will send all incoming requests directed at given server alias. Below is what my .conf file looks like. I am having problems with the first rule associated with foo.com. The rewrite for requests with the alias foo.com simply does not happen. I am not even sure how to debug this...

    NameVirtualHost xxx.xx.x.194
    <VirtualHost xxx.xx.x.194>
     ServerName foo.com
      ServerAlias www.foo.com

      RewriteEngine on
      RewriteRule ^(.*)$ /cgi-bin/redirect.py?url=spencer [L,QSA,PT]
      SetEnv force-proxy-request-1.0 1
      SetEnv proxy-nokeepalive 1
    <VirtualHost xxx.xx.x.194>
     ServerName bar.com
     ServerAlias www.bar.com

     Include /etc/httpd/conf.d/zumodo.common

     ErrorLog logs/zumodo_errors_log
     CustomLog logs/zumodo_log combined
      SetEnv force-proxy-request-1.0 1
      SetEnv proxy-nokeepalive 1
share|improve this question
Are you saying you want the rewrite to happen on requests to foo.com, but not to www.foo.com? Or to both? If it's both, then that looks fine; try setting a RewriteLog and turn up RewriteLogLevel 9. –  Shane Madden Dec 6 '11 at 22:23
I want to rewrite to both. Where do I set RewriteLog and RewriteLogLevel and where will the logs be? –  Peter Dec 6 '11 at 22:24
note I am using etc/http/conf/http.conf –  Peter Dec 6 '11 at 22:25
Also when I add this command, nothing get logged to this log... –  Peter Dec 6 '11 at 22:30

2 Answers 2

Try with

RewriteRule /?(.*) /cgi-bin/redirect.py?url=spencer [L,QSA,PT]

For debugging, try adding:

RewriteLog "/var/log/apache2/rewrite.log"
RewriteLogLevel 3
share|improve this answer

This rule:

RewriteRule ^(.*)$ /cgi-bin/redirect.py?url=spencer [L,QSA,PT]

means: "redirect all the requests to /cgi-bin/redirect.py?url=spencer"

Is that what you actually want to do?

If no, please give two examples of Incoming URLs and how they should be transformed.

Anyway here are my 2 usual hints:

Two hints:

Please try to use the RewriteLog directive: it helps you to track down such problems:

# Trace:
# (!) file gets big quickly, remove in prod environments:
RewriteLog "/web/logs/mywebsite.rewrite.log"
RewriteLogLevel 9
RewriteEngine On

My favorite tool to check for regexp:

http://www.quanetic.com/Regex (don't forget to choose ereg(POSIX) instead of preg(PCRE)!)

share|improve this answer

Your Answer


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.