.htaccess 301将旧的动态URL重定向到新的动态URL
我的.htaccess如下所示.htaccess 301将旧的动态URL重定向到新的动态URL,.htaccess,mod-rewrite,redirect,.htaccess,Mod Rewrite,Redirect,我的.htaccess如下所示 Options +FollowSymLinks RewriteEngine On RewriteRule ^condos-([^-]*)-([^-]*)\.html$ /fm /cond_new?r_id=$1&location=$2 [L] 上面的URL是我的旧动态URLhttp://localhost/fm/condos-2-delhi.html 我的新动态URL是http://localhost/fm/delhi/2/condos和.htacces
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^condos-([^-]*)-([^-]*)\.html$ /fm
/cond_new?r_id=$1&location=$2 [L]
上面的URL是我的旧动态URLhttp://localhost/fm/condos-2-delhi.html
我的新动态URL是http://localhost/fm/delhi/2/condos
和.htaccess具有以下模式
RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)/?$ /fm
/condo_new?location=$1&r_id=$2&name=$3 [L]
现在我想要所有模式http://localhost/fm/condos-2-delhi.html
应重定向到http://localhost/fm/delhi/2/flavor
带有301重定向。
其中风味是产品的名称
我试了一下,但没有成功
RedirectMatch 301 ^condos-([^-]*)-([^-]*)\.html$ ^([^/.]+)/([^/.]+)
/([^/.]+)/?$
您可以在
/fm/.htaccess
中使用此规则:
RewriteRule ^(condos)-([^-]+)-([^-]+)\.html$ /fm/$3/$2/$1 [L,NC,R=301]
请确保这是您在
上重写引擎下面的第一条规则,该规则有效,但我现在编辑了我的问题,因为我在新url中错误地提到了公寓
,但它是产品名称
,而不是公寓。请帮助编辑的问题没有多大意义,因为http://localhost/fm/condos-2-delhi.html
无法重定向到http://localhost/fm/delhi/2/flavor
。您的原始URL中没有flavor
,因此我应该如何处理此问题:(htaccess无法查询您的数据库,以便将productId获取到productName
。您需要在PHP代码中处理此问题。