[英]Rewrite rule not working
I'm breaking my head in redirecting a few page from my old asp website to my new php website. 我正在把我的旧asp网站的几页重定向到我的新php网站。
For example, I want to redirect permanently the following 2 pages from my asp website to my php website 例如,我想将以下2页从我的asp网站永久重定向到我的php网站
1) http://www.mywebsite.com/shopdisplayproducts.asp?id=11&cat=food&sortorder=mostrecent&page=1&pagesize=12 1) http://www.mywebsite.com/shopdisplayproducts.asp?id=11&cat=food&sortorder=mostrecent&page=1&pagesize=12
TO 至
http://www.mywebsite.com/index.php?route=product/category&path=10_11 http://www.mywebsite.com/index.php?route=product/category&path=10_11
where 11 should be the link between old and new website to display the correct page. 其中11应该是新旧网站之间的链接,以显示正确的页面。
2) shopexd.asp?id=3903&prod=food&vrnt=green&mrk=studio&cat=11 2)shopexd.asp?id = 3903&prod = food&vrnt = green&mrk = studio&cat = 11
TO 至
index.php?route=product/product&path=10_11&product_id=3903 的index.php?路线=产品/产品&路径= 10_11&PRODUCT_ID = 3903
where the number 11 is the link between old and new url for the category and the number 3903 is the link for the product number 其中数字11是该类别的旧网址和新网址之间的链接,数字3903是产品编号的链接
I have the following rewrite rule in my htaccess page for the first redirect, but it seems not be triggered. 我的htaccess页面中有第一个重定向的以下重写规则,但似乎没有被触发。 What is wrong? 怎么了? Please help. 请帮忙。
RewriteCond %{REQUEST_URI} ^/shopdisplayproducts\.asp\?id=([0-9]+).*$ [NC]
RewriteRule ^shopdisplayproducts\.asp\?id=([0-9]+).*$ index.php?route=product/category&path=10_$1 [R=301,L]
I also tried: 我也尝试过:
RewriteCond %{REQUEST_URI} ^shopdisplayproducts\.asp\?id=([0-9]+).*$ [NC]
RewriteRule ^shopdisplayproducts\.asp\?id=([0-9]+).*$ index.php?route=product/category&path=10_$1 [R=301,L]
Thanks for any help Sabko 感谢Sabko的任何帮助
You need to use QUERY_STRING
variable in rule condition: 您需要在规则条件中使用QUERY_STRING
变量:
RewriteEngine On
# /shopexd.asp?id=3903&prod=food&vrnt=green&mrk=studio&cat=11 to
# /index.php?route=product/product&path=10_11&product_id=3903
RewriteCond %{QUERY_STRING} ^id=(\d+)&.*&cat=(\d+) [NC]
RewriteRule ^shopexd\.asp$ /index.php?route=product/category&path=10_%2&product_id=%1 [R=301,NC,L]
RewriteCond %{QUERY_STRING} ^id=(\d+) [NC]
RewriteRule ^shopdisplayproducts\.asp$ /index.php?route=product/category&path=10_%1 [R=301,NC,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.