Created
December 4, 2012 14:07
-
-
Save uolter/4204256 to your computer and use it in GitHub Desktop.
Rewrite rule based on cookie and matching URI for preview landing page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine on | |
RewriteLog /var/log/apache2/rewrite.log | |
RewriteLogLevel 5 | |
# Check whether the cookie role exists and whether the url does not contain PRV.shtml | |
# if so it executes the rewrite rule | |
RewriteCond %{HTTP_COOKIE} role=(.*) | |
RewriteCond %{REQUEST_URI} !^.*_PRV.* | |
RewriteRule /art/(.*).shtml /art/$1_PRV.shtml [NC,QSA] | |
# se esiste il cookie e se la url non e' del tipo *_PRV.* => rimuovo il cookie | |
# it the cookie exists and the url does not contain _PRV => it gets rid of the cookie. | |
RewriteCond %{HTTP_COOKIE} role=(.*) | |
RewriteCond %{REQUEST_URI} !^.*_PRV.* | |
Header set Set-Cookie "role='INVALID';expires='Thu, 01-Jan-1970 00:00:01 GMT';Path=/" | |
# se il file richiesto e' di tipo *_PRV.* ma il file non esiste => eseguo rediriect su una pagina di cortesia | |
# if the filename contains _PRV and it does not exist on the file system it executes a redirect to a landing page. | |
RewriteCond %{REQUEST_FILENAME} ^.*_PRV.* | |
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f | |
#RewriteRule /art/(.*)_PRV.shtml /art/redirectmax2.shtml [NC,QSA,L] | |
RewriteRule /art/(.*)_PRV.shtml /art/default.shtml [NC,QSA,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment