繁体   English   中英

重写规则不起作用

[英]Rewrite rule not working

我正在把我的旧asp网站的几页重定向到我的新php网站。

例如,我想将以下2页从我的asp网站永久重定向到我的php网站

1) http://www.mywebsite.com/shopdisplayproducts.asp?id=11&cat=food&sortorder=mostrecent&page=1&pagesize=12

http://www.mywebsite.com/index.php?route=product/category&path=10_11

其中11应该是新旧网站之间的链接,以显示正确的页面。

2)shopexd.asp?id = 3903&prod = food&vrnt = green&mrk = studio&cat = 11

的index.php?路线=产品/产品&路径= 10_11&PRODUCT_ID = 3903

其中数字11是该类别的旧网址和新网址之间的链接,数字3903是产品编号的链接

我的htaccess页面中有第一个重定向的以下重写规则,但似乎没有被触发。 怎么了? 请帮忙。

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]

我也尝试过:

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]

感谢Sabko的任何帮助

您需要在规则条件中使用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.

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