Page 1 of 1

[Solved] MOD REWRITE that ignores a certain directory?

Posted: Sat May 19, 2007 11:12 am
by Dale
I know nothing is impossible in the world ofprogramming, though I've became stumped on the wonders that are .htaccess files. I have this following piece of code that makes http://www.someurl.com/something goto http://www.someurl.com/foo.php?bar=something

Code: Select all

Options +FollowSymLinks
RewriteEngine on
RewriteRule /(.*)$ /foo.php?bar=$1
However doing this makes all myimages (in /images/) disappear, because I suppose they're trying to be located in /foo.php?bar=images/some.jpg (he he) though is there a way that I can get it to not use MOD_REWRITE on the images folder yet still work for everything else?

Posted: Sat May 19, 2007 1:11 pm
by Ollie Saunders
Something similar to this

Code: Select all

RewriteCond %{REQUEST_URI} !/(names|of|directories|not|to|be|rewritten)/

Posted: Sun May 20, 2007 4:21 am
by Dale
ole wrote:Something similar to this

Code: Select all

RewriteCond %{REQUEST_URI} !/(names|of|directories|not|to|be|rewritten)/
Tried that, but doesn't seem to work. :/

Posted: Sun May 20, 2007 4:28 am
by Kieran Huggins
before, try:

Code: Select all

RewriteRule ^folder_name/.*$ - [PT]
That should match your directory name and abort the rest of the rules.

Posted: Sun May 20, 2007 5:38 am
by Ollie Saunders
Attempt 2:

Code: Select all

RewriteCond %{REQUEST_URI} !/(names|of|directories|not|to|be|rewritten)/.*

Posted: Sun May 20, 2007 8:27 am
by thiscatis
real life example that use:

Code: Select all

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/shop.* [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]  
RewriteCond %{REQUEST_FILENAME} -d        
RewriteRule ^(.+) - [PT,L]
it excludes a specific folder, a real existing folder or filename.

Posted: Tue May 22, 2007 4:13 am
by Dale
ole wrote:Attempt 2:

Code: Select all

RewriteCond %{REQUEST_URI} !/(names|of|directories|not|to|be|rewritten)/.*
Always gives me Internal Server Error (500). :/

Posted: Tue May 22, 2007 4:18 am
by Ollie Saunders
Well this works for me

Code: Select all

RewriteEngine On
RewriteCond %{REQUEST_URI} !/(style|gfx|script)/.*
RewriteRule .* bootstrap.php

Posted: Tue May 22, 2007 4:25 am
by Dale
I checked out Thread: 67177 and the example in their worked, plus your one did too ole. :)

Cheers.