11

Apache mod_rewrite:在使用插件域时特别向我解释 %{HTTP_HOST}

具有附加域的 Apache 服务器上的情况(目录树):

main-domain.com/ 
| 
|_ .htaccess (just an empty file, no rule in here) 
|_ index.html (shown when accessing http://main-domain.com)
| 
|_ addon-domain-1.com/ 
|  | 
|  |_ .htaccess 
|  |_ index.html (shown when accessing http://addon-domain-1.com or http://main-domain.com/addon-domain-1.com/)
| 
|_ addon-domain-2.com/ 
   | 
   |_ .htaccess 
   |_ index.html (shown when accessing http://addon-domain-2.com or http://main-domain.com/addon-domain-2.com/)

假设在“addon-domain-1.com/.htaccess”文件中,我有一些使用 %{HTTP_HOST} 的规则,例如:

RewriteCond %{HTTP_HOST} ^something$

是否%{HTTP_HOST}评估服务器上当前请求的 url 的域???

因此,如果要求:

http://addon-domain-1.com/

%{HTTP_HOST} will be "addon-domain-1.com"?

http://addon-domain-1.com(没有最后的斜线)

%{HTTP_HOST} will still be "addon-domain-1.com"?

http://www.addon-domain-1.com

%{HTTP_HOST} will still be "www.addon-domain-1.com"?

当要求:

http://main-domain.com/addon-domain-1.com

%{HTTP_HOST} will be "main-domain.com"???
or "main-domain.com/addon-domain-1.com"???
4

2 回答 2

6

%{HTTP_*}计算为在显示的前缀后给出的名称的 HTTP 标头。在 HTTP 1.1 中,被访问的主机在Host标头中给出,所以是的。

于 2010-07-15T02:41:11.343 回答
5

你几乎猜对了!最后一个是;

main-domain.com
于 2010-07-15T02:38:05.110 回答