What is wrong with this mod_rewrite expression?

I need to replicate functionality mod_aliasthat I cannot use directly because I am on a shared hosting and Alias ​​claims do not work in .htaccess.

What I want to achieve is basically

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]

it will never match the challenges www.example.com/manual.

Why not? What am I doing wrong?

0
source share
2 answers

Try:

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

?means an optional character /in addition to closing the wedge on .to secure /manual, /manual/and /manual/a/b/calthough I am collecting a slash, the apache pre -rewrite usually added is anyway.

, :

/manual/a/b?c=d -> /www/customer/some_other_dir/manual/$2
+2

Multiviews

Options -Multiviews

, / URL.

- www.example.com/manual.

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

Source: https://habr.com/ru/post/1731190/


All Articles