i need some help while migrating an old shopsystem from apache to nginx. Within apache there was no need to do anything. i guess the shopsystem was somehow optimized to handle those URLs. I dont have any mod_rewrite rules doing some magic. However what i need to do is rewriting urls in a certain pattern
desired behaviour:
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
example urls:
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
i want to keep the URL as it is, just doing some internal rewrite.
Any kind of help is apprreciated!
CodePudding user response:
http://www.shop.de/login.php/action/process
should rewrite to http://www.shop.de/login.php?action=process
location / {
rewrite ^/login.php/action/(.*)$ /login.php?action=$2$query_string;
}
CodePudding user response:
For my products I have a rewrite like this:
RewriteRule ^shop(\d |)/([\w_-]*)_([0-9] )\.html$ shop$1/product_info.php?products_name=$2&products_id=$3 [L,QSA]
An url looks like
/shop/motorezina-metzeler-feelfree-wintec-110-70r13-r13-110-70-48p-tl-perednyaya-front_3571287.html