2016-07-11 3 views
0

Je suis en train de lire que correspond réellement à l'ensemble du domaine, pas seulement à l'emplacement racine. Je veux créer un Location ou LocationMatch bloc qui correspond à tout sauf http://my.domain.com/ Cela signifie qu'il déclenchera si des caractères suivent cette dernière «/Apache LocationMatch tout sauf la racine

Voici comment je vais tester ceci:

<LocationMatch "REGEX GOES HERE"> 
    AuthType Shibboleth 
    ShibRequireSession On 
    Require Shibboleth 
</LocationMatch> 

Je pense Shibboleth peut changer un comportement. Notez également que j'utilise Apache 2.2, mais une solution qui fonctionne sur 2.4 suffira également.

Répondre

0

Vous pouvez utiliser LocationMatch cette regex:

<LocationMatch "^/."> 

</LocationMatch> 

unique DOT après ^/ se assurer qu'il ya au moins un caractère après http://my.domain.com/ provoquant donc à ne pas correspondre à la page d'atterrissage.

More details about LocationMatch

Test:

Créer cette directive comme:

<LocationMatch "^/(?<sitename>.+)"> 
    RewriteEngine On 
    RewriteCond %{HTTP_HOST} !^www\. 
    RewriteRule^http://www.%{HTTP_HOST}%{REQUEST_URI}?u=%{env:MATCH_SITENAME} [L,R=302] 
</LocationMatch> 

Maintenant, pour tester ce que je fais:

curl -kI -A "Chrome" -L 'http://localhost/index.php' 
HTTP/1.1 302 Found 
Date: Mon, 11 Jul 2016 22:31:37 GMT 
Server: Apache/2.4.12 (Unix) OpenSSL/1.0.1j PHP/5.6.9 mod_wsgi/3.5 Python/2.7.9 
Location: http://www.localhost/index.php?u=index.php 
Content-Type: text/html; charset=iso-8859-1 

HTTP/1.1 200 OK 
Date: Mon, 11 Jul 2016 22:31:37 GMT 
Server: Apache/2.4.12 (Unix) OpenSSL/1.0.1j PHP/5.6.9 mod_wsgi/3.5 Python/2.7.9 
X-Powered-By: PHP/5.6.9 
Content-Type: text/html; charset=UTF-8 

curl -kI -A "Chrome" -L 'http://localhost/user.php' 
HTTP/1.1 302 Found 
Date: Mon, 11 Jul 2016 22:33:57 GMT 
Server: Apache/2.4.12 (Unix) OpenSSL/1.0.1j PHP/5.6.9 mod_wsgi/3.5 Python/2.7.9 
Location: http://www.localhost/user.php?u=user.php 
Content-Type: text/html; charset=iso-8859-1 

HTTP/1.1 200 OK 
Date: Mon, 11 Jul 2016 22:33:57 GMT 
Server: Apache/2.4.12 (Unix) OpenSSL/1.0.1j PHP/5.6.9 mod_wsgi/3.5 Python/2.7.9 
X-Powered-By: PHP/5.6.9 
Content-Type: text/html; charset=UTF-8 

curl -kI -A "Chrome" -L 'http://localhost' 
HTTP/1.1 200 OK 
Date: Mon, 11 Jul 2016 22:32:47 GMT 
Server: Apache/2.4.12 (Unix) OpenSSL/1.0.1j PHP/5.6.9 mod_wsgi/3.5 Python/2.7.9 
X-Powered-By: PHP/5.6.9 
Content-Type: text/html; charset=UTF-8 

Vous pouvez clairement voir que la redirection wwwne se produit pas quand je demande la page d'atterrissage, mais qui arrive quand je demande /index.php

+0

Ceci est déclenché sur la racine aussi bien ... J'ai ajouté quelques précisions sur la façon dont Je teste ceci, peut-être que Shibboleth change de comportement – JLewkovich

+0

J'ai ajouté des informations de test pour montrer comment cette directive fonctionne correctement – anubhava

+0

Je teste maintenant avec 'Header set X-TEST-ME" TESTING "' et il apparaît sur toutes les URLs ... Je pense que vous pouvez résoudre ce partiellement en utilisant RewriteRules, j'espère une solution plus propre – JLewkovich