Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

Excluding selected file extensions in a RewriteCond

2:13 pm on Dec 22, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:Dec 5, 2002
votes: 0

I use the below code in a .htaccess file. With the middle 5 lines I exclude some file extensions, but is there a better way to do this?

RewriteCond %{REQUEST_URI} \/.+\/
RewriteCond %{REQUEST_URI}!.*\.css
RewriteCond %{REQUEST_URI}!.*\.jpg
RewriteCond %{REQUEST_URI}!.*\.gif
RewriteCond %{REQUEST_URI}!.*\.zip
RewriteCond %{REQUEST_URI}!.*\.js
RewriteRule ^(.*)/ cheats.php?action=showtitles&platform=$1 [L]

5:40 pm on Dec 22, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
votes: 0


I'm not sure what you mean by "a better way", but you can make it more compact:

RewriteCond %{REQUEST_URI} \/.+\/
RewriteCond %{REQUEST_URI} !.*\.(css¦jpg¦gif¦zip¦js)
RewriteRule ^(.*)/ cheats.php?action=showtitles&platform=$1 [L]

(Remember to replace any broken vertical pipe "¦" characters in code posted on WebmasterWorld with a solid vertical pipe characters before use!)