Ronni
Ronni

Reputation: 57

Remove/ redirect part of url string (.htaccess)

I have some duplicate urls with some parts I would like to remove (redirect).

For example: http://www.mydomain.dk/tryksager?pop=0

I would like to remove the ?pop=0 and 301 redirect to: http://www.mydomain.dk/tryksager

This is so that google will not use the ?pop=0. It needs to work on all pages the have the ?pop=0 part in it.

Upvotes: 2

Views: 525

Answers (1)

Felipe Alameda A
Felipe Alameda A

Reputation: 11809

Try just removing the query string, like this:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^pop.*$ 
RewriteRule (.*)  http://www.mydomain.dk/tryksager? [L]

It can be pop or any other label. Important to define it, though. Otherwise it will remove all queries.

UPDATED:

Assuming pop is the constant, try this:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^pop.*$ 
RewriteRule ^(.*)$   http://www.mydomain.dk/$1? [L]

Upvotes: 1

Related Questions