htaccess的指令发生冲突,与QUOT; DocumentRoot的变化" +"始终显示子域" [英] .htaccess instructions conflict "DocumentRoot change" + "always display subdomain"
问题描述
我有一个改变,从 /的public_html
我的DocumentRoot /的public_html / MAIN
重写和它的伟大工程。
I have a rewrite that changes my DocumentRoot from /public_html
to /public_html/MAIN
and it works great.
RewriteRule ^$ /MAIN/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/MAIN/
RewriteRule ^(.*)$ /MAIN/$1
现在如果我尝试添加下面的指令总是显示 WWW
子域,它不再表现正常...
Now If I try to add the following instruction to always show the www
subdomain, it no longer behaves properly...
RewriteCond %{http_host} ^domain.com [nc]
RewriteRule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
访问 http://domain.com/
导致重写 http://www.domain.com/MAIN/
这不是我想要的。 我不希望主
子目录可见。的
Visiting http://domain.com/
causes a rewrite to http://www.domain.com/MAIN/
which is not what I want. I do not want the MAIN
subdirectory to be visible.
我在想什么?
推荐答案
在 ^(。*)$
模式捕捉当前的URI,不管它是在地址栏中或者它是一个内部重定向。其中一个解决办法应该工作:
The ^(.*)$
pattern captures the current URI, no matter it's in the location bar or it's an internal redirection. One of these solutions should work:
- 将子域名重定向第一个
- 替换
$ 1
有一个变量,例如%{REQUEST_URI}
- Put the subdomain redirection first
- Replace
$1
with a variable, e.g.%{REQUEST_URI}
这篇关于htaccess的指令发生冲突,与QUOT; DocumentRoot的变化" +"始终显示子域"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!