I have a basic Magento (PHP app, using index.php as the controller) setup on an Ubuntu server. I configured NGINX to use PHP-CGI to serve all PHP pages. While the site is working as expected, all the URLs are of the form:
http://domain.com/index.php/apparel/shoes.html
Is there a way to use the nginx rewrite setting so that I can have the URLs like this instead:
http://domain.com/apparel/shoes.html
Currently, this is what I have in the configuration file to handle page requests:
# catch rewritten and standard URLs
location ~* ^(/index.php)?(.*) {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/index.php$1;
fastcgi_read_timeout 600;
}
Thanks.
I have some experience with nginx in this regard and have even written about it. So in a shameless act of self-promotion here is the result of my earlier research:
http://www.magentocommerce.com/boards/viewreply/211050/Six years on and the above link is dead. Also my nginx configs are more mature. The following starts by blocking all files and only allowing those which are explicitly public. All other requests are rewritten to
index.php. If you want to execute some other PHP file you must write your own exclusion. This is the safest way I can think of./etc/nginx/magento_server:
/etc/nginx/conf.d/php.conf:
Each store then has it’s own server block similar to this:
/etc/nginx/sites-enabled/yoursite.com:
And since
.htaccessfiles are ignored (because this is not Apache) it helps to put.user.iniin each web root:/var/www/.user.ini