301重定向旧的动态网址到新的动态URL [英] 301 Redirect old dynamic URL to new dynamic URL

查看:275
本文介绍了301重定向旧的动态网址到新的动态URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的.htaccess样子如下

 选项+了FollowSymLinks
RewriteEngine叙述上
重写规则^公寓 - ([^  ​​- ] *) - ([^  ​​- ] *)\ HTML $ / FM
/ cond_new R_ID = $ 1安培;位置= $ 2 [L]
 

以上的网址是我的旧动态网址的http://localhost/fm/condos-2-delhi.html

我的新动态URL是的http://本地主机/ FM /德里/ 2 /公寓和.htaccess有以下模式

 重写规则^([^ /] +)/([^ /] +)/([^ /] +)/?$ / FM
?/ condo_new位置= $ 1安培; R_ID = $ 2及名称= $ 3 [L]
 

现在我想模式的所有网址的http://localhost/fm/condos-2-delhi.html 应重定向到 HTTP:/ /本地主机/ FM /德里/ 2 /味道与301重定向。 其中,风味产品的名称。

我试过如下,但没有成功。

  RedirectMatch 301 ^公寓 - ([^  ​​- ] *) - ([^  ​​- ] *)\ HTML $ ^([^ /] +)/([^ / 。] +)
/([^/.]+)/?$
 

解决方案

您可以使用此规则 /fm/.htaccess

 重写规则^(公寓) - ([^  ​​- ] +) - ([^  ​​- ] +)。\ HTML $ / FM / $ 3 / $ 2 / $ 1 [L,NC, R = 301]
 

确认这是低于 RewriteEngine叙述你的第一个规则在

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$ ^([^/.]+)/([^/.]+)
/([^/.]+)/?$

解决方案

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.

这篇关于301重定向旧的动态网址到新的动态URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆