Daniel Garcia Sanchez
Daniel Garcia Sanchez

Reputation: 2344

htaccess redirection of url with param like p=2

Need to redirect

http://www.example.com/es/?p=2%3Fp%3D2

to

http://www.example.com/es/

I tried with 301, and with rewriterule, but without luck Thanks in advance,

Upvotes: 1

Views: 61

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

You can use the following RewriteRule

RewriteEngine on

RewriteCond %{THE_REQUEST} /es/\?p=.+ [NC]
RewriteRule ^ /es/? [L,R=301]

The empty question mark ? at the end of the rule's target is important as it discards the old querystring. Don't remove this otherwise you will get a redirect loop error.

Upvotes: 1

Related Questions