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
 

3 Responses to Using mod_rewrite with VirtualDocumentRoot

  1. Lewis says:

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

  2. Roger says:

    Same thing for me. Using
    RewriteBase /
    got things working again.

    I tried the PT flag, but still didn’t work for me on a simple rewrite rule. I guess I could dig a little deeper, but for now, I’ve logged it as a workaround with a note to revisit if there are other problems that come up.

    But VirtualDocumentRoot is probably one of the greatest things I’ve found in a long time.

    Roger

  3. 31. I do accept as true with all the concepts you’ve presented to your post. They’re very convincing and can definitely work. Nonetheless, the posts are very short for beginners. Could you please prolong them a bit from subsequent time? Thanks for the post.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>