I'm migrating a website from a server that has Apache web-server to another server that is running Nginx web-server, and I wanted to convert the .htaccess files, the problem is not just the syntax but also the file name, is it also ".htaccess" or what?
Nginx does not use . htaccess files like Apache does. This means that configuration previously done in . htaccess files now has to be done in a different format, explained in the Nginx documentation.
import your . htaccess to nginx. conf (maybe the htaccess to nginx converter helps you) use authd-htpasswd (I didn't try it)
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.
Here's a tool I use:
http://www.anilcetin.com/convert-apache-htaccess-to-nginx/
It is not 100% accurate but it's pretty good base
Also, here's a link about converting the rules:
http://nginx.org/en/docs/http/converting_rewrite_rules.html
This one can help a little:
http://wiki.nginx.org/HttpRewriteModule#rewrite
EDIT:
The file name should be nginx.conf
Nginx does not have support for .htaccess files.
But .htaccess files are bad. It's a way to put parts of the apache configuration erverywhere on the filesystem and to tell apache to check the filesystem at every request to see if you do not have some special configuration in place. The only real usage of .htaccess file is to delegate a small part of the configuration to the user if you are a host provider and wanted to allow some web server configuration for your users.
Nginx configuration is compiled when nginx restart. Of course you can include several files that you can put in your web directory if you really do not care about information disclosure problems (like users seing your web server configuration), but having the same thing as a .htaccess, read each time a request is done, is not in the nginx way.
http://wiki.nginx.org/LikeApache-htaccess:
You can't do this. You shouldn't. If you need .htaccess, you're probably doing it wrong.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With