从 RewriteRule 中排除文件夹/目录 [英] Exclude a folder/directory from RewriteRule

查看:52
本文介绍了从 RewriteRule 中排除文件夹/目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常标准的 WordPress .htaccess 并重写了以下 URL

I have a pretty standard WordPress .htaccess with the following URL rewrites

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

WordPress 安装在我的域根目录中.我在子文件夹中有一些其他脚本,例如/opencart 这些子文件夹包含它们自己的 .htaccess 文件.

WordPress is installed in my domain root. I have some other scripts in subfolders, e.g. /opencart These subfolders contain their own .htaccess files.

不幸的是,WordPress 似乎有时会劫持其中一些脚本的重写.

Unfortunately, it seems that WordPress hijacks the rewrites for some of these scripts sometimes.

当遇到特定子文件夹时,我如何要求 mod_rewrite 忽略 WordPress 重写规则,例如opencart 并改用这些子文件夹中 .htaccess 中定义的规则?

How can I ask mod_rewrite to ignore WordPress rules for rewrites when encountered with specific subfolders e.g. opencart and to use the rules defined in the .htaccess within these subfolders instead?

推荐答案

您可以尝试用这个替换完整的 WP 规则集:

You may try replacing the complete WP rule-set with this one:

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]

# Include in the next line all folders to exclude
RewriteCond %{REQUEST_URI}  !(folder1|folder2|folder3) [NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress 

这篇关于从 RewriteRule 中排除文件夹/目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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