mercoledì 17 dicembre 2008

Some RewriteRule examples

- It means do not parse the rewirte rule:

RewriteCond %{REQUEST_URI} !^http://www.example.it/security/login$ [NC]
RewriteRule .*$ - [F]

- If in the request is not present www.example.it do not serve images

SetEnvIf Referer "^http://www\.example\.it/" sito_ok
SetEnvIf Referer "^$" sito_ok
    Order Allow,Deny
    Allow from env=sito_ok

and if in the request is present www.examples.it insert the image from www.cpcug.org
#www.example.it
Listen 8080
RewriteEngine On
RewriteCond %{HTTP_REFERER} http://www.examples.it/images [NC]
RewriteRule ^.* http://www.cpcug.org/user/deverett/cracked/assets/images/marquee3.jpg [R,L]


- Recreate the request and check the access log for the failing component:

127.0.0.1 - - [23/Jan/2006:08:09:51 -0500] "GET /foo.html HTTP/1.1" 404 317
(core.c/404/handler)
127.0.0.1 - - [23/Jan/2006:08:10:45 -0500] "GET /testcount.jsp HTTP/1.1" 500
644 (mod_was_ap20_http.c/500/handler)
127.0.0.1 - - [23/Jan/2006:08:11:19 -0500] "GET /cgi-bin/printenv HTTP/1.1"
404 322 (mod_cgid.c/404/handler)

- Redirect everything except peppe.html :

           RewriteEngine On
           RewriteCond %{REQUEST_URI} !peppe.html$  [NC]
           RewriteRule ^/(.*)$ https://www.example.it/$1 [L]

- Parse the Rewrite if in the QS (after the "?" in the url) find example_html 

    RewriteEngine on
    RewriteCond %{QUERY_STRING}  example_html
    RewriteRule ^/(.*)$ https://www.example.it/public? [R=301,L]

- Parse the RewriteRule if in the Request URI find

    RewriteCond %{REQUEST_URI} ^/public/example\.jsp$         [OR]
    RewriteCond %{REQUEST_URI} ^/public/example\.html$
    RewriteRule ^/(.*)$   https://www.example.it/$1 [R=301,L]



Nessun commento:

Posta un commento