confiq
confiq

Reputation: 2918

How to urlencode (escape) strings in htaccess?

I have this case in htaccess

RewriteRule ^.*$ https://example.com/ [CO=ref:%{HTTP_REFERER}:example.com:0:/]

All I need is to escape string %{HTTP_REFERER} but after half an hour googling and reading apache docs it seems I can't solve this one :)

So, how do I escape strings in apache?

Upvotes: 2

Views: 874

Answers (1)

anubhava
anubhava

Reputation: 785058

If you want escaping behavior you will need to add this line in your Apache config file:

RewriteMap escape int:escape

Then restart the Apache server.

Further you need to modify your rewrite rule like this:

RewriteRule ^ https://example.com/ [CO=ref:${escape:%{HTTP_REFERER}}:example.com:0:/]

Upvotes: 2

Related Questions