从URL中删除特定的string和查询string
似乎有些人创build链接到我的url与额外的参数,所以谷歌网站pipe理员工具给我服务器错误500 (我甚至不明白为什么谷歌送我服务器错误,因为链接是从外部网站,而不是我的服务器)。 例如: 这是我的url www.example.com/my-post/ 有人用附加的index.php和查询string/index.php?id=123中的随机数字链接到我的文章 并成为www.example.com/my-post//index.php?id=123 (注意额外的斜线)。 在Google网站pipe理员工具中,有太多的抓取错误,例如: www.example.com/my-post//index.php?id=123 www.example.com/my-other-post//index.php?id=1234 www.example.com/my-post-2//index.php?id=12345 问题:如何删除/index.php?id=<random_numbers>并redirect到我的原始发布url,例如www.example.com/<random-posts>/ ? 我试过了 RewriteEngine On RewriteCond %{QUERY_STRING} \bid=(.*) [NC] RewriteRule ^ %{REQUEST_URI}? [L,R] 和 RewriteCond %{QUERY_STRING} ^id=\d+$ [NC] RewriteRule ^ %{REQUEST_URI}? [L,R] 和 RewriteCond %{QUERY_STRING} id RewriteCond %{REQUEST_URI} /index.php RewriteRule ^ %{REQUEST_URI}? [L,R]