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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14008003/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 04:32:22  来源:igfitidea点击:

How to exclude a specific file from a rewriterule

html.htaccessmod-rewriterewrite

提问by Christian

I have been here: How to exclude a specific file in htaccess

我一直在这里:如何在 htaccess 中排除特定文件

and here: exclude files from rewrite rule in .htaccess

在这里:从 .htaccess 中的重写规则中排除文件

but neither worked. What might I be doing wrong?

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

.htaccess file:

.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 [R=301]
RewriteRule ^healthsolutions/(.*)$ http://www.kgstiles.com/healthsolutions [R=301]
RewriteRule ^(.*)\.html$ / [R=301]
RewriteRule ^(.*)\.htm$ / [R=301]
</IfModule>

回答by Felipe Alameda A

To exclude a file, try something like this:

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

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

The rule will be skipped if the file is pureplantessentials.html.

如果文件是pureplantessentials.html.