我们刚刚启动了一个新网站,发现WebMaster工具中有多个Google错误需要修复。在启动之前,我们已经使用重定向301重定向了主要页面,但希望在文件不存在的情况下,为字符串/目录等重写500多个错误。
错误如下:
- /product.php?id=143(多个id)
- /page.php?id=109(多个id)
- /product_42-productname.htm(多个产品名称)
我们能做一个catchall类型的重定向吗?任何以/product开头的页面都会转到一个页面?
我们正在运行一个Wordpress网站,因此当前的htaccess有:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index'.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>'
我们是否需要将其作为该语句的一部分或稍后包含在htaccess文件中?
我们已经尝试了很多选项,但不想在htaccess中列出每一项,只是无法理解如何轻松解决这个问题???
任何帮助,不胜感激。
Ta
您可以捕获违规的"产品"链接,并重定向到index.php,即您的主页。该规则将出现在您的wordpress规则之前,如下所示。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(product|page) /index.php? [R,L]
RewriteRule ^index'.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
该规则将捕获链接,而与它附带的查询参数(id)无关。