.htaccess 通过重写规则修复错误的URL

.htaccess 通过重写规则修复错误的URL,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,谷歌为我的一个网站找到了一个错误的URL,如下所示: mysite.com/9807280/2005-Subaru-Outback// 正确的URL应为: mysite.com/9807280/2005/Subaru/Outback/City/Name/ 坏链接导致我的重写规则中断,页面无法显示,以下是对此的重写: Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-

谷歌为我的一个网站找到了一个错误的URL,如下所示:

mysite.com/9807280/2005-Subaru-Outback//

正确的URL应为:

mysite.com/9807280/2005/Subaru/Outback/City/Name/

坏链接导致我的重写规则中断,页面无法显示,以下是对此的重写:

Options +FollowSymlinks
RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([0-9]+)/?$ /index.php?p=module&prefix=ebosync&module_page=details&id=$1 [NC,QSA,L]
RewriteRule ^([0-9]+)/([0-9]+)/([A-Za-z0-9-_]+)/([A-Za-z0-9-_]+)/([A-Za-z0-9-_]+)/([A-Za-z0-9-_]+)/?$ /index.php?p=module&prefix=ebosync&module_page=details&id=$1&year=$2&make=$3&model=$4&city=$5&dealer=$6 [NC,QSA,L]

解决这个问题的最佳方法是什么,也许可以将两个重写规则合并为一个,并考虑到缺少的参数?

您应该编写一个规则,告诉谷歌更正链接

RewriteRule /broken/ /fixed/ [R=301,l]

R=301将发送HTTP状态301,一旦googlebot再次访问错误的URL,Google将更新他们的索引。

谢谢,我想出了一种使用正则表达式的方法,因此它可以在多个页面上运行