2010-07-14 5 views
7

mod_rewrite Apache: erklären, mich% {HTTP_HOST} expecially wenn Addon-Domains mitApache mod_rewrite: erklären, mich% {HTTP_HOST} expecially wenn Addon-Domains mit

Situation (Verzeichnisse Baum) auf einem Apache-Server mit Addon-Domains:

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/) 

sagen wir mal in "addon-domain-1.com/.htaccess" Datei habe ich einige Regel% mit {} HTTP_HOST wie:

RewriteCond %{HTTP_HOST} ^something$ 

Does %{HTTP_HOST} wertet die Domain der aktuell angeforderten URL auf dem Server aus ???

Also, wenn fragt nach:

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

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

http://addon-domain-1.com (ohne abschließenden Schrägstrich)

%{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"? 

Und wenn fragt nach:

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

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

Antwort

4

Sie ziemlich sie alle richtig erraten! Der letzte wäre;

main-domain.com 
3

%{HTTP_*} wertet auf die HTTP-Header mit dem Namen nach dem Präfix gegeben gezeigt. In HTTP 1.1 wird der Host, auf den zugegriffen wird, im Header Host angegeben, also ja.

Verwandte Themen