views:

302

answers:

2

I have the following rewrite URL:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs 
RewriteRule ^(.*)$ index.php?page=$1 [PT,L]

Now I want to add an exception, that if the URL is something like mysite.com/abc it should ignore it and all things inside it also. mysite.com/abc/dfgs also should be excluded from this rewriting.

How can I accomplish this?

A: 

This should avoid rewriting if the URI contains abc. This may or may not be exactly what you want. If it isn't edit your question.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#Rewrite ONLY if the REQUEST does NOT contain abc
RewriteCond %{REQUEST_URI} !abc

# Rewrite all other URLs 
RewriteRule ^(.*)$ index.php?page=$1 [PT,L]
Vinko Vrsalovic
+1  A: 

If /abc is an existing directory, you can put another .htaccess file in there with

RewriteEngine Off

If it's really just one string you want to not rewrite (whether it exists or not)

RewriteCond %{REQUEST_URI} !^/abc

will not rewrite if the requested path starts with "/abc"

To test rewrite rules without messing up the site for regular browsers (not that you should be editing in a live environment of course, this is purely hypothetical :-) ), I've found the following very helpful:

RewriteCond %{REMOTE_ADDR} 12.34.56.78 # <-- where that's your IP address
MSpreij