公共.htaccess重写规则
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了公共.htaccess重写规则相关的知识,希望对你有一定的参考价值。
Please, be careful with trailing slash rewrite as post requests without a trailing slash will be ignored.Be sure to test if you plan on using that one.
Not compatible with Drupal.
## no-www redirect RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] ## www redirect RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] ## multiple domain redirect RewriteCond %{HTTP_HOST} !^example.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [R=301,L] ## trailing slash ## BE EXTRA CAREFUL WITH THIS ONE! ## POST REQUESTS WITHOUT TRAILING SLASH ## WILL BE IGNORED! RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ http://www.example.com/$1/ [L,R=301]
以上是关于公共.htaccess重写规则的主要内容,如果未能解决你的问题,请参考以下文章