Using Mod_rewrite With VirtualDocumentRoot

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.

If you found this post helpful, please consider sharing to your network. I'm also available to help you be successful with your distributed systems! Please reach out if you're interested in working with me, and I'll be happy to schedule a free one-hour consultation.