views:

35

answers:

2

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?

+2  A: 

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
Aiden Bell
Note that this will also match `/manualasdf`!
Aistina
@Aistina - Good point!, Well caught! Will revise ;)
Aiden Bell
All right, thanks for the revision!
Pekka
I have a follow-up: http://stackoverflow.com/questions/2188444/mod-rewrite-to-absolute-path-in-htaccess-turning-up-404
Pekka
+1  A: 

Tun off Multiviews option

Options -Multiviews

and i think, it's expect / at end of requested URL.

Something like this will match www.example.com/manual too.

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