0
votes

i have requirement to redirect Apache on query base parameters for example

https://example.com/?ampostpreserve=01902018

I need to redirect to https://example.com .. I tried with

RewriteEngine On RewriteCond %{QUERY_STRING} ^ampostpreserv$ RewriteRule (.*) https://example.com [R=301,L]

but seem not working ..any solution

Thanks Hem

1

1 Answers

0
votes

It seems like you just want to drop the query string? The QSD parameter does exactly that. The below version is for every called URL.

  RewriteEngine On
  RewriteCond %{QUERY_STRING} .+
  RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [QSD,L,R=301]

And this is the specific version for example.com and the above query string:

  RewriteEngine On
  RewriteCond %{QUERY_STRING} ^ampostpreserve
  RewriteRule .* https://example.com [QSD,L,R=301]