apache - How to redirect to lowercase when specific url contains at least one capital letter -
i need redirect possible combinations of lower/uppercase url lowercase, 1 specific url example-url
.
sample:
/example-url => /example-url /example-url => /example-url /example-url => /example-url
rewriterule ^example-url(.*)$ /example-url$1 [nc,r=301,l]
cause redirect loop...
thanks help!
you can use lookahead make sure @ least 1 uppercase letter there (?i)
flag make ignore-case after lookahead:
rewriteengine on rewriterule ^(?=[^a-z]*[a-z])(?i)example-url(/.*)?$ /example-url$1 [r=302,l]
(?=[^a-z]*[a-z])
positive lookahead ensure there @ least 1 uppercase letter.(?i)
making rest of pattern ignore case.
an alternative without lookahead:
rewritecond %{request_uri} [a-z] rewriterule ^example-url(/.*)?$ /example-url$1 [r=302,l,nc]
Comments
Post a Comment