Forum Moderators: phranque
the problem is;
I wanna set a general rule for "virtual directories" on the server;
so I wrote this htacces file:
RewriteEngine On
RewriteRule ^([a-zA-Z0-9]*)/([a-zA-Z0-9]*)/ $1.php?page=$2
RewriteRule ^([a-zA-Z0-9]*)/ $1.php
it works! the problem is that I wanna except the directory images and all the subdirectories behind (and the sub-subdirectories and the sub-sub-sub-directories etc...)
I tried to add
RewriteCond %{REQUEST_URI} !/images
But, it works only on the main directory "images" and not on all the subdirectories in it...
any ideas?
thanks ahead!
Oh, BTW sorry for my bad English
MrBean
A note: Since it is unlikely that you want to rewrite URLs where the "[a-zA-Z0-9]" field is blank, I recommend modifying your pattern. In addition, you can make it more efficient by using both the [NC] (No Case) and [L] (last rule) flags, and anchoring your patterns:
RewriteEngine on
#
RewriteCond $1 !^images
RewriteRule ^([a-z0-9]+)/([a-z0-9]+)/$ $1.php?page=$2 [NC,L]
#
RewriteCond $1 !^images
RewriteRule ^([a-z0-9]+)/$ $1.php [NC,L]
Answering indirectly to perhaps pique your interest:
Using [NC] speeds up that letters-and-numbers check by over 33%.
Using [L] tells mod_rewrite not to bother proceeding further into your rules if the current rule matches, again speeding up your server.
Links to other useful documentation are available in our Apache Forum Charter [webmasterworld.com].
Jim