I need to replicate the functionality of mod_alias which I can't use directly because I'm on shared hosting, and Alias statements don't work in .htaccess.

What I want to achieve is essentially

Alias /manual /www/customer/some_other_dir/manual

I am trying mod_rewrite:

RewriteRule ^/manual/(.*) /www/customer/some_other_dir/manual/%1?%{QUERY_STRING} [L]

this will never match any calls to www.example.com/manual.

Why not? What am I doing wrong?

Comments

@Pekka - Check my revision before putting that live! :P

Written by Aiden Bell

Accepted Answer

Try:

RewriteRule ^/manual(/(.*))?$ /www/customer/some_other_dir/$2 [L]

The ? means optional for the / character in addition to the kleene closure on the . to ensure /manual, /manual/ and /manual/a/b/c although I gather a slash is usually added by apache pre-rewrite engine anyway.

A quick test on my box shows this rule also passes the query string:

/manual/a/b?c=d -> /www/customer/some_other_dir/manual/$2
Written by Aiden Bell
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki