301 将旧动态 URL 重定向到新动态 URL
301 Redirect old dynamic URL to new dynamic URL
我的 .htaccess 如下所示
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^condos-([^-]*)-([^-]*)\.html$ /fm
/cond_new?r_id=&location= [L]
以上URL是我的老动态URLhttp://localhost/fm/condos-2-delhi.html
我的新动态 URL 是 http://localhost/fm/delhi/2/condos
并且 .htaccess 具有以下模式
RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)/?$ /fm
/condo_new?location=&r_id=&name= [L]
现在我希望模式 http://localhost/fm/condos-2-delhi.html
的所有 URL 都应使用 301 重定向重定向到 http://localhost/fm/delhi/2/flavor
。
其中 flavor 是产品名称。
我试过如下但没有成功
RedirectMatch 301 ^condos-([^-]*)-([^-]*)\.html$ ^([^/.]+)/([^/.]+)
/([^/.]+)/?$
您可以在 /fm/.htaccess
中使用此规则:
RewriteRule ^(condos)-([^-]+)-([^-]+)\.html$ /fm/// [L,NC,R=301]
确保这是您下面的第一个规则 RewriteEngine On
。
我的 .htaccess 如下所示
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^condos-([^-]*)-([^-]*)\.html$ /fm
/cond_new?r_id=&location= [L]
以上URL是我的老动态URLhttp://localhost/fm/condos-2-delhi.html
我的新动态 URL 是 http://localhost/fm/delhi/2/condos
并且 .htaccess 具有以下模式
RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)/?$ /fm
/condo_new?location=&r_id=&name= [L]
现在我希望模式 http://localhost/fm/condos-2-delhi.html
的所有 URL 都应使用 301 重定向重定向到 http://localhost/fm/delhi/2/flavor
。
其中 flavor 是产品名称。
我试过如下但没有成功
RedirectMatch 301 ^condos-([^-]*)-([^-]*)\.html$ ^([^/.]+)/([^/.]+)
/([^/.]+)/?$
您可以在 /fm/.htaccess
中使用此规则:
RewriteRule ^(condos)-([^-]+)-([^-]+)\.html$ /fm/// [L,NC,R=301]
确保这是您下面的第一个规则 RewriteEngine On
。