开发者

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]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜