views:

30

answers:

1

Hi! I got problems with the following two lines:

RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+[^/])$ /$1.html [L]

Goal: Redirecting "domain.tld/test/" (only if test.html exists) so that it outputs the contents of "domain.tld/test.html".

  • How to make this case-insensitive: "domain.tld/Test" -> domain.tld/test.html **
  • How to make it accept a trailing slash: "domain.tld/test/" should work, too

Thanks!

** I couldn't get RewriteMap lowercase int:tolower to work, any help appreciated.

A: 

Try this:

RewriteRule (.+)/$ $1
RewriteCond %{DOCUMENT_ROOT}/${tolower:$1}.html -f
RewriteRule ^(.+[^/])$ /$1.html [L]

Furthermore RewriteMap can only be used in the server configuration or virtual host context but not in a .htaccess file. So you need to define the rewrite map there.

Gumbo