Welcome to WebmasterWorld Guest from 54.80.102.170

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

[mod_rewrite] How to exclude a folder?

Exclude a folder in mod_rewrite

     
6:26 am on Jul 15, 2003 (gmt 0)

Full Member

10+ Year Member

joined:Jan 19, 2003
posts:324
votes: 0


Good day,
I wrote the following .htaccess to rewrite my site:
RewriteEngine On
RewriteRule ^(.*)/ dir.php?name=$1

In this way, all URLs like
[mysite.com...] will rewrite to
[mysite.com...]

However, I do not want to rewrite exist folders becase there are some folder like /images/ could not be used correctly any more. Is there a way to exclude these exist folders from the rewrite rule?

Edit: Sorry the topic should be: How to exclude...

7:24 am on July 15, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 7, 2003
posts:1230
votes: 0


hi iProgram, welcome to webmasterworld [webmasterworld.com].

use a RewriteCond (Rewrite-Condition) for this. You place it one line before the Rewrite-Rule, so the Rewrite-Rule will only be executed if the condition matches. the condition should be: directory does not exist.


RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ...

something like this should do the job (not tested). documentation [httpd.apache.org].

- hakre

7:34 am on July 15, 2003 (gmt 0)

Full Member

10+ Year Member

joined:Jan 19, 2003
posts:324
votes: 0


Thanks.
Answer:
RewriteCond %{REQUEST_URI}!^/images/