Eric
Eric

Reputation: 97571

How can I encode a query string with htaccess

I want to redirect

http://myoldsite.com/page?query=some+arguments&some_more

To

'http://mynewsite.com/?notfound=' + urlencode('page?query=some+arguments&some_more')

Is this possible with htaccess alone?

Upvotes: 2

Views: 577

Answers (1)

anubhava
anubhava

Reputation: 785128

You can use a combination of B and NE flags to escape the back-references:

RewriteEngine On

RewriteCond %{QUERY_STRING} .+
RewriteRule ^page/?$ /?notfound=$0\%3f%0 [L,NC,R=302,B,NE]

Upvotes: 2

Related Questions