markup-validator commit: Do uri=referer redirects in httpd.conf if mod_rewrite is available.

changeset:   3216:b453edae6d5a
user:        Ville Skyttä <ville.skytta@iki.fi>
date:        Sun Mar 13 12:37:00 2011 +0200
files:       httpd/conf/httpd.conf
description:
Do uri=referer redirects in httpd.conf if mod_rewrite is available.


diff -r 086cd5c82567 -r b453edae6d5a httpd/conf/httpd.conf
--- a/httpd/conf/httpd.conf	Sun Mar 13 12:35:39 2011 +0200
+++ b/httpd/conf/httpd.conf	Sun Mar 13 12:37:00 2011 +0200
@@ -11,11 +11,22 @@
 # To run the validator without mod_perl 2.x even if it is loaded, comment
 # out the "IfDefine MODPERL2" sections below.
 
-# Legacy: support /check/referer by redirecting to check?uri=referer
+# Referer dependent redirects.
 
 <IfModule mod_rewrite.c>
 RewriteEngine On
-RewriteRule ^(/+w3c-validator/+check)/+referr?er\b $1?uri=referer [R=301,QSA,L]
+
+# check/referer is deprecated in favor of check?uri=referer
+RewriteRule ^(/+w3c-validator/+check)/+referr?er$ $1?uri=referer [R=301,QSA,L]
+
+# If Referer is present, redirect check?uri=referer to check?uri=$Referer
+RewriteRule . - [E=have_uri_referer:false]
+RewriteCond %{QUERY_STRING} (^|.*?[;&])ur[il]=referer([;&].*|$)
+RewriteRule . - [E=qs1:%1,E=qs2:%2,E=have_uri_referer:true]
+RewriteCond %{ENV:have_uri_referer} =true
+RewriteCond %{HTTP_REFERER} ^(.+)$
+RewriteRule ^/+w3c-validator/+check$ \
+            /w3c-validator/check?%{ENV:qs1}uri=%1%{ENV:qs2} [R,B,NE,L]
 </IfModule>
 
 # Tell httpd that check and sendfeedback.pl are CGI scripts.

Received on Sunday, 13 March 2011 11:12:08 UTC