排除重写规则的子域

时间:2016-07-16 16:34:03

标签: wordpress apache .htaccess mod-rewrite

我的主站点是下一个.htaccess

# To externally redirect /dir/file.php to /dir/file
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.+?)\.php[\s?] 
RewriteRule ^ /%1 [R=301,L,NE]

# To internally forward /dir/file to /dir/file.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ /$1.php [L]

在我的子域名中我只安装wordpress,但是我的主站点的重写规则打破了我的wordpress的导航,如何从我的主域规则中排除我的子域?

我试试这个,但不工作

# don't apply any rewrites to the subdomain
RewriteCond %{HTTP_HOST} ^subdomain\.mysite\.com$
RewriteRule .* - [L]

在我的wordpress forlder的.htaccess中我有这个

# 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

任何想法如何解决这个问题? 提前谢谢

1 个答案:

答案 0 :(得分:0)

在您的主网站.htaccess中使用

# To externally redirect /dir/file.php to /dir/file
RewriteCond %{HTTP_HOST} !^subdomain\.mysite\.com$ [NC] 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.+?)\.php[\s?] 
RewriteRule ^ /%1 [R=301,L,NE]

# To internally forward /dir/file to /dir/file.php
RewriteCond %{HTTP_HOST} !^subdomain\.mysite\.com$ [NC] 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ /$1.php [L]