如何从重写文件中排除特定文件

时间:2012-12-23 01:40:35

标签: html .htaccess mod-rewrite rewrite

我来过这里:How to exclude a specific file in htaccess

在这里:exclude files from rewrite rule in .htaccess

但都没有奏效。我可能做错了什么?

.htaccess文件:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^wp-content(/.*|)$ - [L] # don't take any action
RewriteRule ^wp-admin(/.*|)$ - [L] # don't take any action
RewriteRule ^wp-includes(/.*|)$ - [L] # don't take any action
RewriteCond %{REQUEST_URI} !^/pureplantessentials\.html$

RewriteRule ^moreinfo/(.*)$ http://www.kgstiles.com/moreinfo$1 [R=301]
RewriteRule ^healthsolutions/(.*)$ http://www.kgstiles.com/healthsolutions$1 [R=301]
RewriteRule ^(.*)\.html$ $1/ [R=301]
RewriteRule ^(.*)\.htm$ $1/ [R=301]
</IfModule>

1 个答案:

答案 0 :(得分:30)

要排除文件,请尝试以下操作:

RewriteCond %{REQUEST_URI} !^/pureplantessentials\.html$ 

如果文件为pureplantessentials.html,则会跳过该规则。