【问题标题】:How to exclude a specific file from a rewriterule如何从重写器中排除特定文件
【发布时间】:2012-12-10 02:07:03
【问题描述】:

我一直在这里: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>

【问题讨论】:

  • ¿从什么重写到什么?请举一些例子。根据您的规则集,不可能猜到。
  • 我想从我的其余规则中排除特定文件。我将在上面的编辑中发布我的 htaccess 文件。

标签: html .htaccess mod-rewrite rewrite


【解决方案1】:

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

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

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

【讨论】:

  • 它仍在重写。它应该有一个特定的地方吗?我把它放在我排除的末尾...
  • 这就是为什么一个例子很重要。请使用示例更新您的答案,以查看带有要排除的文件的传入 URL 的外观。
  • 我应该发布我更新的 .htaccess 文件并向您展示它的外观吗?
  • 我刚刚在我的问题中发布了我的 htaccess 文件。 www.kgstiles.com/pureplantessentials.html 仍然重定向到 www.kgstiles.com/pureplantessentials/
  • 我不确定这是否是您的错误,或者我所做的事情是否与我上面所说的相反,但是通过将 RewriteCond %{REQUEST_URI} !^/pureplantessentials\.html$ 更改为RewriteCond %{REQUEST_URI} !^pureplantessentials\.html$(没有第一个 /),我能够完成这项工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-06-10
  • 2012-07-23
  • 2011-08-11
相关资源
最近更新 更多