Apache的mod_rewrite规则 [英] Apache mod_rewrite rule

查看:107
本文介绍了Apache的mod_rewrite规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下网址:

<$p$p><$c$c>http://hostname/Numark-iDJ-Live-DJ-software-controller-for-iPad-iPhone-or-iPod/product/?mid=1&pid=B004JPPO94&src=hmb_numark

(也行,的Numark ..到ipod ..'是'标题')

我想写一个规则,这个URL重定向到以下网址

<$p$p><$c$c>http://hostname/product/?sid=1&pid=B004JPPO94&title=Numark-iDJ-Live-DJ-software-controller-for-iPad-iPhone-or-iPod&src=hmb_numark

请注意第一个URL包含中期和PID,而第二个包含PID和SID。

是否有人可以帮助我,指导我朝重写规则,将这种情况下工作?

感谢你。


解决方案

旧网址:

<$p$p><$c$c>http://hostname/Numark-iDJ-Live-DJ-software-controller-for-iPad-iPhone-or-iPod/product/?mid=1&pid=B004JPPO94&src=hmb_numark

新网址:

<$p$p><$c$c>http://hostname/product/?sid=1&pid=B004JPPO94&title=Numark-iDJ-Live-DJ-software-controller-for-iPad-iPhone-or-iPod&src=hmb_numark

我不知道如果这就是你真正想要的,你还没有完全指定的问题。此规则也预计中期,PID和src在URL和给定的顺序所有present。

  RewriteEngine叙述在
(。*)的RewriteCond%{QUERY_STRING}中旬=安培; PID =&AMP(*)(。*)SRC =
(。*)重写规则/产品/产品/ SID =%1安培; PID =%2及标题= $ 1安培; SRC =%3 [R = 301,L]

I am using the following URL:

http://hostname/Numark-iDJ-Live-DJ-software-controller-for-iPad-iPhone-or-iPod/product/?mid=1&pid=B004JPPO94&src=hmb_numark

(also, the 'Numark.. to ipod..' is the 'title')

I want to write a rule to redirect this URL to the following URL

http://hostname/product/?sid=1&pid=B004JPPO94&title=Numark-iDJ-Live-DJ-software-controller-for-iPad-iPhone-or-iPod&src=hmb_numark

note the first url contains mid and pid while the second contains pid and sid.

Can someone please help me out and direct me towards the rewrite rule that would work for this case?

Thank You.

解决方案

Old URL:

http://hostname/Numark-iDJ-Live-DJ-software-controller-for-iPad-iPhone-or-iPod/product/?mid=1&pid=B004JPPO94&src=hmb_numark

New URL:

http://hostname/product/?sid=1&pid=B004JPPO94&title=Numark-iDJ-Live-DJ-software-controller-for-iPad-iPhone-or-iPod&src=hmb_numark

I have no idea if that's what you actually want as you haven't fully specified the question. This rule also expects that mid, pid and src are all present in the URL and in the given order.

RewriteEngine On
RewriteCond %{QUERY_STRING} mid=(.*)&pid=(.*)&src=(.*)
RewriteRule (.*)/product/ product/?sid=%1&pid=%2&title=$1&src=%3 [R=301,L]

这篇关于Apache的mod_rewrite规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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