What is the nginx equivalent of .htaccess What is the nginx equivalent of .htaccess nginx nginx

What is the nginx equivalent of .htaccess


Since Nginx does not have an equivalent to the .htaccess file (i.e. no directory level configuration files), you need to update the main configuration and reload nginx for any changes to take effect.

The above Apache config essentially reads "if the path provided isn't an existing file or a directory, redirect to index.php, appending the path".

In Nginx, you will use the try_files directive to accomplish the same thing:

location / {        try_files $uri $uri/ @ci_index;}location @ci_index{        rewrite ^(.*) /index.php?$1 last;}

By default, the configuration file is named nginx.conf and placed in the directory /usr/local/nginx/conf , /etc/nginx or /usr/local/etc/nginx