Forum Moderators: phranque

Message Too Old, No Replies

Exclude directory from all url rewriting (.htaccess)

         

thing3b

2:08 pm on Dec 11, 2004 (gmt 0)

10+ Year Member



I have searched and I can not seem to figure out how to exclude a directory from any url rewritting. After looking arround, the only way I can see this being done is with something like:

rewriteCond %{REQUEST_URI}!^/(imagedirĶimagedir2Ķimagedir3)/

The problem with this is that it has to be done for every rewritting rule. This is a real problem when your htaccess file is quite big.
So how can I stop all rewritting rules from affecting one directory?

Span

2:38 pm on Dec 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could also put an .htaccess in the directory you want to exclude with RewriteEngine off in it.

jdMorgan

3:46 pm on Dec 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



rewriteCond %{REQUEST_URI} !^/(imagedirĶimagedir2Ķimagedir3)/

The problem with this is that it has to be done for every rewritting rule. This is a real problem when your htaccess file is quite big.

So how can I stop all rewritting rules from affecting one directory?

Actually, you can put a new rule ahead of the ones that you don't want to run for those subdirectories:


RewriteRule ^(imagedirĶimagedir2Ķimagedir3) - [L]

This tells mod_rewrite to leave the URL unchanged and quit processing rules if the requested subdirectory is one of those in the alternate list. If the requested subdirectory is in the list, all the rules after this one get skipped.

Jim

thing3b

1:45 am on Dec 12, 2004 (gmt 0)

10+ Year Member



Thank you very much,
I did not realise that there was a "no substitution field" (the dash).
That was exactly what I wanted.