由于过去对该网站的黑客攻击,我们在Google(site:ourdomain.ch)中有数百个索引文件,如下所示:
ourdomain.ch/index.php?02374234999 ourdomain.ch/index.php?wer99234234
1)这些URL不会被重定向,仅显示另一个URL来显示主页的内容(请参见上文)。我认为这是SEO明智的问题,即重复内容。对吧?
2)我无法将这些文件重定向到根目录。没办法。我将该行添加到现有的.htaccess中:
RewriteRule ^ index.php \?123 /index.php [R = 301,L]
只是要使用ourdomain.ch/index.php进行测试?123 它重定向到:ourdomain.ch/?123。不是我想要的...
更新的.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php\?123 /index.php [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
有人提示如何实现吗?
非常感谢您的帮助。
干杯, 切萨雷
答案 0 :(得分:1)
您需要使用RewriteCond
RewriteCond %{QUERY_STRING} ^.+$
RewriteRule ^index\.php$ /index.php? [L,R=301]
这会将/index.php?foobar
重定向到/index.php
,从index.php中删除查询字符串。