I am trying to force all my URLs to be lowercase, but in doing so, I lose the connection to all my site assets.

I've added this to my in my .conf file:

RewriteMap lc int:tolower

And this to my .htaccess:

RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule . ${lc:%{REQUEST_URI}} [R=301,L]

This is added before my final index.php declaration within the mod_rewrite area of the .htaccess

I'll post my full htaccess to view. http://pastebin.com/PsSsVVeR

Can you see what I'm doing wrong?
I apologise, but I'm relatively new at apache configuration.

  • Apache and Linux are case sensitive. So if a directory/file is example.com/hoG/heaVEn, then the HTTP request would have to match. As as matter of consistency, most people create their site with all lowercase but not always. Check your directory names and file names for mixed case.
    – closetnoc
    Mar 5, 2015 at 15:45
  • closetnoc has a point, although I had assumed (before answering below) that you'd already checked that directly requested lowercase URLs already functioned correctly?
    – MrWhite
    Mar 6, 2015 at 13:01

1 Answer 1


I think the error is where you have placed these directives in your .htaccess file:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

# New directives inserted...
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule . ${lc:%{REQUEST_URI}} [R=301,L]

RewriteRule .* index.php [L]
RewriteRule ^index.php/(.*)$ [L]

The first 3 RewriteCond directives should apply to the RewriteRule .* index.php [L] directive - to prevent your site assets (files that exist) from being rewritten - but you've stuck your new directives in the middle! RewriteCond directives apply to the single RewriteRule that follows. As it is now, all your site assets are going to be redirected (internally rewritten) to index.php - which will make them "disappear"!

Try moving your two directives to the top of your .htaccess file (after you've enabled the RewriteEngine).

  • Great spot! Thanks for this. However, I've done so, but if I try and redirect to /admin for example, (which is lowercase, and redirects to another, lowecase url) I'm redirected to /%5bl%5d which is bizarre. Can you help.
    – Dan Hanly
    Mar 9, 2015 at 10:51
  • Actually, I think I've found the source of my issues, but it goes deeper than I thought, so I'll mark you as correct (as in essence, it does solve my issue in a nutshell)
    – Dan Hanly
    Mar 9, 2015 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.