Using mod_rewrite with VirtualDocumentRoot

January 21, 2009 – 8:33 pm

In our dev environment, we use VirtualDocumentRoot to avoid configuring new environments when we get a new developer. It’s awesome.

However, if you try to use mod_rewrite, you’ll find that your rewrite rules will prepend whatever you have defined as the document root in the config file. To get around this, you have to use the PT (passthrough) flag, which will solve the issue.

Example:

RewriteRule ^/photo/(.*) /open.php?id=$1 [L,NE,PT]

Found here, on an apache archive.

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit
  1. One Response to “Using mod_rewrite with VirtualDocumentRoot”

  2. RewriteBase /
    Seems to do the trick for me too. I’ve not tested it thoroughly though.

    By Lewis on Jul 22, 2010

Post a Comment