Rewriting URL'S

Discuss practical ways rearrange URLs using mod_rewrite.

Rewriting URL'S

Postby psycholuz » Sat Apr 09, 2005 12:34 am

Hi everybody, i'm new to mod_rewrite, and i'm testing with it, i like to rewrite my url's trying to catch any cliente request.
This is my .htaccess
RewriteEngine On

RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK) [NC,OR]
RewriteCond %{HTTP_REFERER} (poker) [NC,OR]
RewriteCond %{HTTP_REFERER} (casino) [NC,OR]
RewriteCond %{HTTP_REFERER} (SPAM) [NC,OR]
RewriteCond %{HTTP_REFERER} (buy) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (Program\ Shareware|Fetch\ API\ Request) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (Microsoft\ URL\ Control) [NC]
RewriteRule .* - [F]

RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR]
RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR]
RewriteCond %{HTTP_USER_AGENT} ^CherryPicker [OR]
RewriteCond %{HTTP_USER_AGENT} ^NICErsPRO [OR]
RewriteCond %{HTTP_USER_AGENT} ^Teleport*28 [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailCollector
RewriteRule ^.*$ /php/problem.php [L]

RewriteCond %{REQUEST_FILENAME} .*jpg$|.*gif$|.*png$ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !example\.com [NC]
RewriteCond %{HTTP_REFERER} !google\. [NC]
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
RewriteRule (.*) /php/showpic.php?pic=$1

RewriteRule (.*)/index\.(htm|html|php)(/?)$ $1/ [R,L]

RewriteBase /
RewriteRule ^(.*)\.(htm|html|php)$ $1 [C,E=Wa.html:yes]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [S=2]
RewriteCond %{REQUEST_FILENAME}.htm -f
RewriteRule ^(.*)$ $1.htm [S=1]
RewriteCond %{ENV:Wa.html} ^yes$
RewriteRule ^(.*)$ $1

RewriteRule ^(cgi-bin|cache)(/.*)?$ - [S=2]
RewriteRule ^(.*)\.(css|cgi|jpg|png|gif)$ - [S=1]
RewriteRule ^(.*)_(.*)$ /$1-$2 [R=301,L]

It works as i like, but i'm sure that it can be improved, any suggestions?
psycholuz
 
Posts: 1
Joined: Sat Apr 09, 2005 12:27 am
Location: Spain

Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 9 guests

cron