0

I need to remove all links that have a question mark. These are links not indexed by Google.

I can't find a solution to this problem.

Example:

http://example-page.pl/pl?start=18 --> http://example-page.pl/pl

HTACCESS:

...

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

...

Gary Thomas
  • 2,291
  • 1
  • 9
  • 21

1 Answers1

0

Use a RewriteCond to check if there is a query string, then using RewriteRule redirect only the first part of the url.


Input: http://example-page.pl/pl?start=18

RewriteCond %{QUERY_STRING} .
RewriteRule ^(.*)$ /$1? [R,L]

Output: http://example-page.pl/pl


You can view this working via htaccess.madewithlove.be.

Gary Thomas
  • 2,291
  • 1
  • 9
  • 21