如何忽略 mod_rewrite 中的目录? [英] How do I ignore a directory in mod_rewrite?

查看:16
本文介绍了如何忽略 mod_rewrite 中的目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让 modrewrite 规则跳过目录 vip.正如您在下面看到的,我尝试了很多方法,但都无济于事.

I'm trying to have the modrewrite rules skip the directory vip. I've tried a number of things as you can see below, but to no avail.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#RewriteRule ^vip$ - [PT]
RewriteRule ^vip/.$ - [PT]
#RewriteCond %{REQUEST_URI} !/vip 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

如何让 modrewrite 完全忽略 /vip/ 目录,以便所有请求直接传递到文件夹?

How do I get modrewrite to entirely ignore the /vip/ directory so that all requests pass directly to the folder?

为了清楚起见:

  • 它托管在 Dreamhost 上
  • 文件夹位于 wordpress 目录中
  • /vip/文件夹包含 webdav .htaccess 等(虽然我认为这并不重要

推荐答案

尝试将此放在任何其他规则之前.

Try putting this before any other rules.

RewriteRule ^vip - [L,NC] 

它将匹配任何以 vip 开头的 URI.

It will match any URI beginning vip.

  • - 表示什么都不做.
  • L 表示这应该是最后一条规则;忽略后面的一切.
  • NC 表示不区分大小写(因此VIP"也匹配).
  • The - means do nothing.
  • The L means this should be last rule; ignore everything following.
  • The NC means no-case (so "VIP" is also matched).

注意它匹配任何beginning vip.表达式 ^vip$ 将匹配 vip 但不匹配 vip/vip/index.html.$ 可能是你的垮台.如果你真的想把它做对,你可能想用 ^vip(/|$) 这样你就不会匹配 vip-page.html

Note that it matches anything beginning vip. The expression ^vip$ would match vip but not vip/ or vip/index.html. The $ may have been your downfall. If you really want to do it right, you might want to go with ^vip(/|$) so you don't match vip-page.html

这篇关于如何忽略 mod_rewrite 中的目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆