[thelist] quick url rewrite help

David Kaufman david at gigawatt.com
Sun Feb 18 12:24:50 CST 2007

John DeStefano <john.destefano at gmail.com> wrote:
> I'm trying to [...] get a sub-sub-dir "/a/b/c" to be accessible
> via a sub-dir "/a/c"  [...] I assume I'm screwing up syntax
> somehow.
> For example:
> RewriteRule ^/a/c(.*) /a/b/c$1 [R]
> This comes up as a 404 error.  Any idea why?

Try this (int the VirtualHosts's document_root):

RewriteEngine On
RewriteBase /
RewriteRule a/c(.*)$ a/b/c$1 [R]

Somtimes it's difficult (and sometimes it's impossile) to match the leading slash or get a leading ^ to match anything, because during certain of the Apache request phases, the absolute path (up to and including the trailing slash) of the doc_root has been stripped out of the internal variable that the RewriteRule is testing (and rewriting).



More information about the thelist mailing list