Kohjah Breese
Kohjah Breese

Reputation: 4136

Create two environmental variables with one RewriteCond

I have query strings like:

?request=/de/name/dieter

Using the below rule I catch the last part (dieter) and store it as an environmental variable. I'd also like to be able to store the first part of the URL (de) as an environmental variable, but I can't find a way to do that. Is it possible.

Rule at current:

RewriteCond %{QUERY_STRING} ^request=([a-z\/]*)name\/(.*?)([^/]{3})([^/]+) [NC]
RewriteRule .* - [E=N:%2%3/%4]
RewriteRule .* - [E=LANG:%1]

Upvotes: 2

Views: 145

Answers (1)

Michael Berkowski
Michael Berkowski

Reputation: 270637

Generally, the "rewrite flags" [] portion of a RewriteRule accepts a comma-separated list of flags, and the RewriteRule docs do not explicitly say that you may not repeat a flag. Since E= is a flag, it should work to provide a comma-separated list of E= along with other rewrite flags (like [L] if needed)

RewriteCond %{QUERY_STRING} ^request=([a-z\/]*)name\/(.*?)([^/]{3})([^/]+) [NC]
RewriteRule .* - [E=N:%2%3/%4,E=LANG:%1]

Upvotes: 2

Related Questions