2017-04-09 42 views
0

我需要一些幫助,同時將舊的商店系統從apache遷移到nginx。 在Apache內部,不需要做任何事情。我想商店系統是以某種方式優化來處理這些網址。我沒有任何mod_rewrite規則做一些魔術。但是我需要做一定的模式被重寫URLnginx重寫規則來生成搜索引擎友好的舊網址xtcommerce 3.04 sp 2.1商店系統

所需的行爲:

Replace 1st/after Filename ending with (.php) with ? 
Replace 2nd/with = 
Replace 3rd/with & 
Replace 4th/with = 
[repeat 3/4] as long as there are parameters inside the URL 

例如網址:

http://www.shop.de/login.php/action/process 
should rewrite to => http://www.shop.de/login.php?action=process 

OR

http://www.shop.de/product_info.php/info/p283_foo-bar.html/action/add_product 

should rewrite to ==> http://www.shop.de/product_info.php?info=p283_foo--bar.html&action=add_product 

我想保留網址,只是做一些內部重寫。

任何類型的幫助apprreciated!

回答

0

http://www.shop.de/login.php/action/process 應改寫爲http://www.shop.de/login.php?action=process

location/{ 
    rewrite ^/login.php/action/(.*)$ /login.php?action=$2$query_string; 
} 
+0

例URL只是'登錄.php「,但這並不意味着這將是唯一的一個URL。您的示例在其他情況下不起作用。 – kworr

0

對於我的產品我有這樣的重寫:

RewriteRule ^shop(\d+|)/([\w_-]*)_([0-9]+)\.html$ shop$1/product_info.php?products_name=$2&products_id=$3 [L,QSA] 

的URL看起來像

/shop/motorezina-metzeler-feelfree-wintec-110-70r13-r13-110-70-48p-tl-perednyaya-front_3571287.html 
相關問題