Michael Trachsel
Michael Trachsel

Reputation: 109

.htaccess redirect to lowercase ignored in subfolder

I have a .htaccess that redirects everything to it's lower-case equivalent. For example:

example.com/HellO/WorLd -> example.com/hello/world

Here is my .htaccess:

RewriteEngine on
RewriteBase /
RewriteMap lowercase int:tolower
RewriteCond $1 [A-Z]
RewriteRule ^/?(.*)$ /${lowercase:$1} [R=301,L]

Is it possible to overwrite this beheviour in the subfolder /admin? So that example.com/admin/WorLd would not change?

Thank you in advance.

Upvotes: 1

Views: 42

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

You can use RewriteCond to exclude the /admin folder from your RewriteRule.

Put the following condition right above your RewriteRule line :

RewriteCond %{REQUEST_URI} !^/admin [NC]

Upvotes: 2

Related Questions