Search code examples
.htaccesshttp-redirecthttp-status-code-301

301 redirect of home page with query parameters to without query parameters


domain com/?fwcc=1&fwcl=1&fwl=1

First of all, I do not know from where this URL came as I tried to search but no answer available, just a guess might be from facebook but I want to get rid of it as it is showing me as duplicate content.

I tried to implement 301 redirect but no success tried different solutions e.g

RewriteRule ^/? http://www.domain.com/? [L,R=301]
RewriteRule ^/?fwcc=1&fwcl=1&fwl=1$ http://www.domain.com/? [L,R=301]

And this solution but no success. Please suggest by the way I am using Drupal7.5


Solution

  • You cant match against querystring in rule's pattern. You need to match against the_request variable using a RewriteCond

    RewriteEngine on
    RewriteCond %{THE_REQUEST} /\?fwcc=1 [NC]
    RewriteRule ^ /? [L,R]