V.Nice V.Nice - 2 months ago 6x
Apache Configuration Question

How to create a regex that looks for a word in any combination?

I am curious to know how to write a regex to replace the following I use for .htaccess managing my page urls. The point of the Regex is to identify any combination of letters whether they are upper or lower case so that I don't have to think of each combination like the following example....

RewriteRule ^(about-us|About-Us|About-us|ABOUT-US)$ about-us.php [L]

However what if I dont think of a combo, how can I write a regex that does this?

So far the closest I have come is...

^([about\-us|ABOUT\-US])$ about-us.php [L]


Rather than using a complicated regex I suggest using NC (no case) flag to make your rule ignore case:

RewriteRule ^about-us/?$ about-us.php [L,NC]