簡體   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