通过问号重定向/删除链接

时间:2018-11-20 08:54:11

标签: .htaccess redirect

我需要删除所有带有问号的链接。这些是Google未索引的链接。

我找不到解决此问题的方法。

示例:

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]

...

1 个答案:

答案 0 :(得分:0)

使用RewriteCond检查是否存在查询字符串,然后使用RewriteRule仅重定向URL的第一部分。


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

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

输出:http://example-page.pl/pl


您可以通过htaccess.madewithlove.be查看此工作。

相关问题