0

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!

MrBomsch
  • 1
  • 2

2 Answers2

0

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;
}
Richard-Degenne
  • 2,892
  • 2
  • 26
  • 43
  • Example URL was only `login.php` but this doesn't means that that would be the only one URL. Your example would not work in other cases. – kworr Jul 04 '17 at 18:40
0

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
lazy.lizard
  • 834
  • 6
  • 11