Forum Moderators: phranque
I have written some rewrite rules and they are working fine. In the rewrite log I find this -
prefixed with document_root to....
and it works well.
Now the same rewrite rules I have wrapped in a VirtualHost directive and it stopped working.
Looking at the rewrite log I found that now it is not prefixing with document root and hence the problem. I could get rid of it by using the PT flag in my rewrite rule but was very curious as to why after using VirtualHost it stops prefixing with doc root.
Any help would be appreciated.
Thanks.
The rules in a per-directory override file (.htaccess) are written relative to the directory they reside in. If you move those rulesets into your per-server configuration file (httpd.conf) you need to make the rules relative to the root path.
Note: Pattern matching in per-directory context
Never forget that Pattern is applied to a complete URL in per-server configuration files. However, in per-directory configuration files, the per-directory prefix (which always is the same for a specific directory) is automatically removed for the pattern matching and automatically added after the substitution has been done. This feature is essential for many sorts of rewriting - without this, you would always have to match the parent directory which is not always possible.There is one exception: If a substitution string starts with ``http://'', then the directory prefix will not be added, and an external redirect or proxy throughput (if flag P is used) is forced!
mod_rewrite [httpd.apache.org]