I have this rewrite rule:
RewriteRule ^/?([a-z]{2})/(printers|hdd|scanners|--some 40 more items go here --)/
Note the part (printers|hdd|scanners|–some 40 more items go here –)? There are some 40 items that go in there. Is there an easier way to do this rule instead of including all those 40 items in there? And it’s not just one rule, there are several rules like this.
I know I can do something like the rule below, but problem is, if a user typed http://www.domain.com/us/foo, it would still get tru. Whereas, if I included only the item names, it would throw an error if the names where not found.
RewriteRule ^/?([a-z]{2})/([a-zA-z0-9\-]+)/?$
Any easier way to do this? Can we store values in a variable and use that variable in other parts of the htaccess page like we do in php?
No, if you don’t want to let everything through, then you have to explicitly list all the ones you want. You can either do that or use something like a RewriteMap, which requires server/vhost config access.