NGinx Best Practices
- by The Pixel Developer
What best practices do you use while using NGinx?
try_files in Subdirectory
Credits go to Igor for helping me with this one.
location /wordpress {
try_files $uri $uri/ @wordpress;
}
location @wordpress {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(/wordpress)(/.*)$;
fastcgi_param SCRIPT_FILENAME /var/www/wordpress/index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
Normally PATH_INFO would include the "/wordpress", so we use the "split_path_info" command to grab the part of the URI after "/wordpress". This allows us to wordpress with and without the index.php file.