简体   繁体   English

我如何将带有查询字符串的asp网址重定向到php网址

[英]How do I redirect an asp url with query string to php url

There is an old link coming to my site that ends with sc_purchase_a.asp?discode=foo&ProID=bar. 我的网站上有一个旧链接,以sc_purchase_a.asp?discode = foo&ProID = bar结尾。 I want to redirect that to /courses/shop/4u.php?discode=foo. 我想将其重定向到/courses/shop/4u.php?discode=foo。 This is what I've done so far, but its not working. 这是我到目前为止所做的,但是没有用。

RewriteRule ^sc_purchase_a.asp?discode=(\w+)&ProdID=(\w+)/?$ /courses/shop/4u.php?discode=$1 [QSA]

This doesnt seem to work. 这似乎不起作用。

Based on starkeen's answer, I came up with this, but it is not working and now gives me 500 errors. 根据starkeen的回答,我想到了这个,但是它不起作用,现在给我500个错误。

RewriteCond %{THE_REQUEST} /sc_purchase_a\.asp\?discode=([^&]+)&ProID=.+ [NC]
RewriteRule ^ /courses/shop/4u.php?discode=%1 [L,R]

QueryString is not part of match in RewriteRules pattern. QueryString不是RewriteRules模式中匹配项的一部分。 To manupulate query string ,you need to use a RewriteCond 要处理查询字符串,您需要使用RewriteCond

RewriteEngine on


RewriteCond %{THE_REQUEST} /page\.asp\?code=([^&]+)&id=.+ [NC]
RewriteRule ^ /page.php?code=%1 [L,R]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM