Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Excluding selected file extensions in a RewriteCond



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

10+ Year Member

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)

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


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!)



Featured Threads

Hot Threads This Week

Hot Threads This Month