frodo
frodo

Reputation: 1063

Explain RewriteCond with %1 in it

Could someone explain the rewrite below please the last two lines in this Rewrite Condition please - I'm unclear what the %1 is actually doing ?

RewriteCond ${domainmappings:%1} ^(.+)$ [NC]
RewriteRule ^ %1 [L,R=301]

Thanks

Upvotes: 2

Views: 265

Answers (1)

ratsbane
ratsbane

Reputation: 890

It's using a RewriteMap to look up the URL in a structure, defined elsewhere, called 'domainmappings'. Look for that RewriteMap directive to get a better idea of what's going on. The %1 refers to the value of the capture group (what's inside the first set of parentheses) in the regular expression. Essentially this is just looking the URL up in a mapping table which is stored in an external file and then replacing the URL with the value from that file.

Upvotes: 1

Related Questions