Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 282 Vote(s) - 3.61 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Nginx rewrite rules for prestashop, how to setup, debug and enable?

#1
I want to change from Apache to Nginx+Php-Fpm for performance reasons. Currently I can see homepage of my website (in test environment) but any friendly url that worked in Apache does not work now.

I have already converted rules to nginx rules but I don't have any way to test it because, every click on some url of the site turns into my browser download the php file!

for example

I click on

[To see links please register here]

and my browser download a php file :-/

Environment Test is

* PHP 5.3.17 (cli) (built: Sep 13 2012 06:45:07)
Copyright © 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright © 1998-2012 Zend Technologies

* nginx -v
nginx version: nginx/1.0.15


Here it is my nginx virtual host config:

server {
server_name site.com

[To see links please register here]

;
root /srv/www/site.com/httpdocs;
access_log /srv/www/site.com/log/access.log;
error_log /srv/www/site.com/log/error.log;
rewrite_log on;
location / {
index index.html index.htm index.php;
rewrite ^/([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1-$2$3.jpg? break;
rewrite ^/([0-9]+)\-([0-9]+)/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1-$2.jpg? break;
rewrite ^/([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$1$2.jpg? break;
rewrite ^/([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$1$2$3.jpg? break;
rewrite ^/([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$1$2$3$4.jpg? break;
rewrite ^/([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg? break;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg? break;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg? break;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg? break;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg? break;
rewrite ^/c/([0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /img/c/$1$2.jpg? break;
rewrite ^/c/([a-zA-Z-]+)/[a-zA-Z0-9-]+\.jpg$ /img/c/$1.jpg? break;
rewrite ^/([0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /img/c/$1$2.jpg? break;
rewrite ^/([0-9]+)\-[a-zA-Z0-9-]*\.html /product.php?id_product=$1 break;
rewrite ^/[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html /product.php?id_product=$1 break;
rewrite ^/([0-9]+)\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+ /category.php?id_category=$1&noredirect=1 break;
rewrite ^/([0-9]+)\-[a-zA-Z0-9-]* /category.php?id_category=$1 break;
rewrite ^/([0-9]+)__([a-zA-Z0-9-]*) /supplier.php?id_supplier=$1 break;
rewrite ^/([0-9]+)_([a-zA-Z0-9-]*) /manufacturer.php?id_manufacturer=$1 break;
rewrite ^/content/([0-9]+)\-([a-zA-Z0-9-]*) /cms.php?id_cms=$1 break;
rewrite ^/content/category/([0-9]+)\-([a-zA-Z0-9-]*) /cms.php?id_cms_category=$1 break;
rewrite ^/pagina-no-encuentra$ /404.php break;
rewrite ^/direccion$ /address.php break;
rewrite ^/direcciones$ /addresses.php break;
rewrite ^/autenticacion$ /authentication.php break;
rewrite ^/mas-vendidos$ /best-sales.php break;
rewrite ^/carro-de-la-compra$ /cart.php break;
rewrite ^/contactenos$ /contact-form.php break;
rewrite ^/descuento$ /discount.php break;
rewrite ^/estado-pedido$ /guest-tracking.php break;
rewrite ^/historial-de-pedidos$ /history.php break;
rewrite ^/identidad$ /identity.php break;
rewrite ^/fabricantes$ /manufacturer.php break;
rewrite ^/mi-cuenta$ /my-account.php break;
rewrite ^/nuevos-productos$ /new-products.php break;
rewrite ^/carrito$ /order.php break;
rewrite ^/devolucion-de-productos$ /order-follow.php break;
rewrite ^/pedido-rapido$ /order-opc.php break;
rewrite ^/vales$ /order-slip.php break;
rewrite ^/contrasena-olvidado$ /password.php break;
rewrite ^/promocion$ /prices-drop.php break;
rewrite ^/buscar$ /search.php break;
rewrite ^/mapa-del-sitio$ /sitemap.php break;
rewrite ^/tiendas$ /stores.php break;
rewrite ^/proveedores$ /supplier.php break;
error_page 404 = /404.php;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}


Worst problem is I don't have some experience to debug the problem :-/ Very new with Nginx
Any comment will be appreciated,

Thanks
Reply

#2
Ok, I've fixed my own issue! It was so easy by the way, only was to change the location of the rules

I've moved all rules of

location /{
.... rules...
}

to

server {

...here rules works...

}

Then I reload nginx and that's it!

service nginx reload

I hope this can be useful for some desperate guy like me.

Best regards,

Ruben
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through