2010-07-14 15 views
7

Apache mod_rewrite: me expliquer% {HTTP_HOST} expecially lors de l'utilisation des domaines addonApache mod_rewrite: me expliquer% {HTTP_HOST} expecially lors de l'utilisation des domaines addon

Situation (répertoires d'arbres) sur un serveur Apache avec des domaines addon:

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

Disons que dans le fichier "addon-domain-1.com/.htaccess" J'ai une règle en utilisant% {HTTP_HOST} comme:

RewriteCond %{HTTP_HOST} ^something$ 

Est-ce %{HTTP_HOST} évalue au domaine de l'URL actuellement demandée sur le serveur ???

Donc, si demander:

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

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

http://addon-domain-1.com (sans barre oblique finale)

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

Et lorsque vous demandez:

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

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

Répondre

4

Vous l'aurez deviné à peu près les bien! Le dernier serait;

main-domain.com 
3

%{HTTP_*} l'en-tête évalue HTTP avec le nom donné après le préfixe indiqué. Dans HTTP 1.1, l'hôte en cours d'accès est indiqué dans l'en-tête Host, donc oui.