Nginx htaccess support may be the most common question for people that are running Apache and thinking about migrating to Nginx web server.
About nginx htaccess support
First of all, .htaccess files are a resource/performance hog, this is not good for website/server speed. Every time Apache handles a request, it first checks and processes any .htaccess file in the same directory as the file it is serving. That’s quite normal, however, not all people know that Apache goes deep down through all the parent directories of the current one, and in every single one of them, it checks for .htaccess files.
For example: visitor is browsing http://www.mypage.com/pages/photography.html and the document root is set to /opt/www/websites/mywebsite.com, this forces Apache to attempt to locate and process .htaccess files in all these directories:
/ /opt /opt/www /opt/www/websites /opt/www/websites/mywebsite.com /opt/www/websites/mywebsite.com/pages
This is the way Apache can handle dynamic rules without restarting/reloading his core, but as you see, it is a resource killer, specially for large websites with tons of traffic.
Another issue with dynamic .htaccess files, is the fact it is really insecure, as it is providing a way to alter server and website settings from a single file that is located inside the home directory of each website. This won’t happen if you have your rules inside Nginx configuration, as only root permission is granted to do so.
If you are a lazy developer you can still working with Apache and it’s .htaccess structure, however if you are serious about performance and security of your apps, now you know another reason why you should use Nginx Rewrite rules.At the end of the day, .htaccess provides a convenient shortcut for the lazy admin or developer, but also kills performance, makes configuration issues more difficult to track down, and opens yet another attack vector on your site.
Popular search terms:
- nginx htaccess
- htaccess nginx
- no htaccess in nginx
- can nginx read htaccess