Apache: Rewrite domain path bug when .htaccess used in non-root dir
How to fix rewrite rule, so that it works also trough domain.com/path/.htaccess?
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
If rule used in domain.com/.htaccess, redirecting works fine:
www.domain.com/path/url -> domain.com/path/url
If rule used in domain.com/path/.htaccess, redirected incorrect:
www.domain.com/开发者_开发知识库path/url -> domain.com/url // Why not domain.com/path/url ?
%{REQUEST_URI}
provides you the full path:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule .* http://%1%{REQUEST_URI} [R=301,L]
精彩评论