1
votes

Recently the site I was working on added language handling in this way: content tailored toward users of a certain language will have urls that start with baseUrl/[a-z]{2}-[a-z]{2}/... (I may be more explicit since this will catch a lot of things that will not work for my use case). The default language will not. The current default language has a lot of rewrite rules and I want a way to globally set up the input used with the rewriter to either be URL path after '/' or after ([a-z]{2}-[a-z]{2}/)? which should be directly after the '/'. The only thing I have thought of that seems to work is convert each rule to a regex and add ([a-z]{2}-[a-z]{2}/)? to the beginning of every rule. Basically I want to apply the rewrite rules I have to sub domains of this site.

1

1 Answers

2
votes

If you do not stop processing after each rewrite rule you could add a rule to "stuff" the language into a server variable which is essentially an HTTP header (Lookup allowed server variables). You can process your rules as normal and then rewrite the language back in if a header value is detected.