Forum Moderators: phranque

Message Too Old, No Replies

[mod_rewrite] How to exclude a folder?

Exclude a folder in mod_rewrite

         

iProgram

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

10+ Year Member



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...

hakre

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

WebmasterWorld Senior Member 10+ Year Member



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

iProgram

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

10+ Year Member



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