0

I have the following rule:

RewriteRule ^([a-z])([\w-]+)/?$ $1.php?var=$2 [L,QSA,NC]

This redirects /fH128 to f.php?var=H128. I would like to be able to have the first character, which identifies the file name, be uppercase, but then redirected to this filename in lowercase. Thus /FH128 would redirect to f.php?var=H128.

I tried the following, but neither work:

RewriteRule ^([a-z])([\w-]+)/?$ ${lowercase:$1}.php?var=$2 [L,QSA,NC]
RewriteRule ^([a-z])([\w-]+)/?$ {lowercase:$1}.php?var=$2 [L,QSA,NC]

1 Answer 1

1

Inside your Apache config files e.g. httpd.conf or virtual host config (but not .htaccess) define this RewriteMap:

RewriteMap lowercase int:tolower

Then inside .htaccess use your rule as:

RewriteRule ^([a-z])([\w-]+)/?$ ${lowercase:$1}.php?var=$2 [L,QSA,NC]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.