1

网站的爬取属性显示

  http://www.abc.com/http://www.abc.com/index.php?option=com_toys
  http://www.abc.com/http://www.abc.com/index.php?option=com_article
  http://www.abc.com/http://www.abc.com/index.php?option=com_play&view=category&vid=10

该网站已像这样被抓取,错误以重复的 url 形式出现。正确的网址是

  http://www.abc.com/index.php?option=com_toys
  http://www.abc.com/index.php?option=com_article
  http://www.abc.com/index.php?option=com_play&view=category&vid=10

有什么办法可以让我尝试使用 301 重定向

  RewriteCond %{REQUEST_URI} ^.*/http://www.abc.com.*$
  RewriteRule .*  index.php     [R=301,L]

但它没有达到重定向到http://www.abc.com/index.php的预期 效果 如何通过 htaccess 从不正确的 url 重定向到正确的 url 结构

4

2 回答 2

1

通过启用 mod_rewrite 和 .htaccess httpd.conf,然后将此代码放在您.htaccessDOCUMENT_ROOT目录下:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+http://.+?(/index\.php\?[^\s]+) [NC]
RewriteRule ^ %1 [R=301,L,NE]
于 2013-07-16T11:16:59.197 回答
0

试试这个代码:

RewriteEngine On
RewriteRule ^http://www.abc.com/index.php /index.php [QSA, R=301]
于 2013-07-16T05:55:47.770 回答