Reputation: 39
I want to change all my URL's with lowercase using RewriteMap lc int:tolower
in my Apache config file an in my htaccess have this regular expression:
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule . ${lc:%{REQUEST_URI}} [R=301,L]
.. and work purfectly! But i have Libraries (with files) and Directories who i don't want to change to lowercase (for example: "Images" with all sub directories or Libraries: "Functions/Liberties/Image/Resize.php") ... how to make it?
I tried with RewriteRule ^(Images) - [NC,QSA,L]
but don't accept it ... any idea how to make this exceptions?
Thank you in advance and sorry for my english!
Upvotes: 0
Views: 333
Reputation: 39
Thank you all ... i fix it with this:
RewriteRule ^Admin/ - [L]
RewriteRule ^Apps/ - [L]
RewriteRule ^Bank/ - [L]
RewriteRule ^Downloads/ - [L]
RewriteRule ^Functions/ - [L]
RewriteRule ^Images/ - [L]
RewriteRule ^Pages/ - [L]
RewriteRule ^Scripts/ - [L]
RewriteRule ^Styles/ - [L]
... and i put it before:
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule . ${lc:%{REQUEST_URI}} [R=301,L]
For me and my case work, i hope it is the right decision. Thank you again!
Upvotes: 0
Reputation: 17805
You can first disable directory listing using -indexes
and now, if the requested URI is an existing directory or a file, you can skip the rewrite rule using !-d
and !-f
params like below:
Options -Indexes
RewriteEngine On
RewriteCond %{REQUEST_URI} [A-Z]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . ${lc:%{REQUEST_URI}} [R=301,L]
Upvotes: 1