301 Redirect old dynamic URL to new dynamic URL

人走茶凉 提交于 2019-12-13 01:36:11

问题


My .htaccess look like as below

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^condos-([^-]*)-([^-]*)\.html$ /fm
/cond_new?r_id=$1&location=$2 [L]

The above URL is my old dynamic URL http://localhost/fm/condos-2-delhi.html

My new dynamic URL is http://localhost/fm/delhi/2/condos and .htaccess has below pattern

RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)/?$ /fm
/condo_new?location=$1&r_id=$2&name=$3 [L]

Now i want all URLs of pattern http://localhost/fm/condos-2-delhi.html shall redirect to http://localhost/fm/delhi/2/flavor with 301 redirect. where flavor is name of product.

I tried as below but no success

RedirectMatch 301 ^condos-([^-]*)-([^-]*)\.html$ ^([^/.]+)/([^/.]+)
/([^/.]+)/?$

回答1:


You can use this rule in /fm/.htaccess:

RewriteRule ^(condos)-([^-]+)-([^-]+)\.html$ /fm/$3/$2/$1 [L,NC,R=301]

Make sure this is your first rule below RewriteEngine On.



来源:https://stackoverflow.com/questions/28062121/301-redirect-old-dynamic-url-to-new-dynamic-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!