如何忽略父目录中的 .htaccess 文件 [英] how to ignore the .htaccess file from a parent directory
问题描述
我正在为搜索引擎优化的 url 使用重写规则在我的根文件夹中,我有以下 .htaccess 文件:
I'm using rewrite rules for search engine optimized url's In my root folder I have the following .htaccess file:
Options +FollowSymlinks RewriteEngine On RewriteCond %{http_host} ^elitegameservers.net [NC]
RewriteRule ^(.*)$ http://www.elitegameservers.net/$1 [R=301,L]
rewriteEngine on
rewriteBase /
rewriteCond %{HTTP_HOST} ^(.*)haloservers(.nl|.us|.net)$
rewriteRule ^(.*) http://www.haloservers.net/$1 [L,R=301]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?haloservers(.nl|.us|.net) [NC]
RewriteRule ^(.*)\.html$ http://www.elitegameservers.net/$1 [R=301,L]
在子目录 (/controlpanel) 中,我使用以下 .htaccess 文件运行 WHMCS:
In the sub directory(/controlpanel) I run WHMCS with the following .htaccess file:
RewriteEngine On
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{http_host} ^elitegameservers.net [NC]
RewriteRule ^(.*)$ http://www.elitegameservers.net/controlpanel/$1 [R=301,L]
RewriteEngine On
# Announcements
RewriteRule ^announcements/([0-9]+)/[a-z0-9_-]+\.html$ ./announcements.php?id=$1 [L,NC]
RewriteRule ^announcements$ ./announcements.php [L,NC]
# Downloads
RewriteRule ^downloads/([0-9]+)/([^/]*)$ ./downloads.php?action=displaycat&catid=$1 [L,NC]
RewriteRule ^downloads$ ./downloads.php [L,NC]
# Knowledgebase
RewriteRule ^knowledgebase/([0-9]+)/[a-z0-9_-]+\.html$ ./knowledgebase.php?action=displayarticle&id=$1 [L,NC]
RewriteRule ^knowledgebase/([0-9]+)/([^/]*)$ ./knowledgebase.php?action=displaycat&catid=$1 [L,NC]
RewriteRule ^knowledgebase$ ./knowledgebase.php [L,NC]
我注意到 WHMCS 中知识渊博的 SEO 优化似乎无法正常工作,这似乎是由我的根目录中的 .htaccess 代码引起的.
I noticed that knowledgeable SEO optimization in WHMCS doesn't seem to work properly and it seems to be caused by the .htaccess code in my root directory.
因此,我希望从根目录中的代码中排除控制面板子目录.
Because of that I want the controlpanel sub directory to be excluded from the code in the root directory.
感谢您的帮助
推荐答案
您可以尝试向根目录中的规则添加条件以排除以 controlpanel
开头的请求:
You could try adding a condition to the rules in your root directory to exclude requests starting with controlpanel
:
RewriteCond %{REQUEST_URI} !^/controlpanel
rewriteCond %{HTTP_HOST} ^(.*)haloservers(.nl|.us|.net)$
rewriteRule ^(.*) http://www.haloservers.net/$1 [L,R=301]
RewriteCond %{REQUEST_URI} !^/controlpanel
RewriteCond %{HTTP_HOST} ^(www\.)?haloservers(.nl|.us|.net) [NC]
RewriteRule ^(.*)\.html$ http://www.elitegameservers.net/$1 [R=301,L]
这篇关于如何忽略父目录中的 .htaccess 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!