I've tried to install and configure Prestashop with minimal amount of manual work to get it up and running on Enhance with nginx installed. Although I'm writing about Prestashop here, same observations also apply to other php-based systems using more than one entry php files.
Enhance generates default location block like this:
location / {
try_files $uri $uri/ =404;
}
With rewrite / => index.php added in Developer Tools in generates:
location / {
try_files $uri $uri/ /index.php?$args;
}
Notice to $args suffix at the end of line.
But any other directory than / dont append $args
For example rewrite /admin123456abcdef => /admin123456abcdef/index.php generates:
location /admin123456abcdef {
try_files $uri $uri/ /admin123456abcdef/index.php;
}
Notice missing $args at the end. No $args at the end breaks urls like Prestashop admin:
https://prestashop.example.eu/admin123456abcdef/index.php/something/etc
It is not possible to add Rewrite via Developer Tools like /admin123456abcdef => /admin123456abcdef/index.php$args since existing file is required as rewrite destination path.
To manual workaround this issue for now add something like this in website override:
location /admin123456abcdef {
try_files $uri $uri/ /admin123456abcdef/index.php?$args;
}
This is commonly used by Enhance community.
But… it would be great if this kind of entry with $args in it would be generated by Enhance while using Rewrite.
I think that adding $args every time when .php file is provided in destination path will be just fine as it does not pose any security issues for most commonly used CMS.
Discussion is welcome!
PS: Related thread by Shoeman: https://community.enhance.com/d/2659-better-nginx-support
PS: Related thread by nhybgtvfr: https://community.enhance.com/d/3403-nginx-vhost-changes-to-location