Probably a lot of friends are commonly used nginx does not support. htaccess, only Apache supports. htaccess file, in fact this is the wrong view Nginx is also supported. Hatccess.
In fact, Nginx and. htaccess a little relationship, just a lot of people by the influence of Apache think Nginx should also support. htaccess function. Just include the. htaccess file directly in the Nginx configuration.
Include/Site Directory/.htaccess;
How simple, but more people laugh and cry is that most people do not know Nginx and Apache is two different webserver program, so many people do: in Nginx include. htaccess file, Upload Apache pseudo-static rules of. htaccess to the site root directory ... No words. In fact, Nginx can include any file, not just. htaccess.
In fact, Nginx is quoted as such. htaccess and Apache are also different, the wording is not the same:
1, Nginx is started to introduce, because Nginx special focus on efficiency, so when the start will be all the configuration file read into memory, and then start a. If a syntax error is found, the startup fails. Apache is dynamically introduced, and each visit to the site is re-loaded into the configuration.
2, the include in Nginx is manually added, specify the directory. Apache has used the. htaccess as a feature mechanism, and all subdirectories of the support station can have. htaccess files.
(The following excerpt from Http://wiki.nginx.org/LikeApache-htaccess)
Like Apache:. htaccess
You can ' t do this. You shouldn ' t. If you need. htaccess, you ' re probably doing it wrong.
Why ?
This is a great question. For-starters, for. htaccess-to-work Apache needs-to-check every directory in the requested path for the existence of a. HT Access file and if it exists it reads every one of them and parses it. This happens for every request. Remember that the second your change that file, it ' s effective. This is because Apache reads it every time.
Numbers
Http://example.com/site/files/images/layout/header.png
Let's say we ' re not doing any funky aliasing and the file system looks like the path. This covers is the most of the sites out there. There is the/directory, then site/, files/, images/, and layout/. This amounts to 5 directories that could has a. htaccess file. Let's say added a. htaccess in/, Files/and images/. That ' s three. htaccess files. That ' s pretty typical.
Now the numbers, that ' s 6 file system stats and 4 file system reads. Including one for the requested file. This happens for every read. We ' ll ignore parsing time because both Nginx and Apache need to does this and we'll consider the difference in time for this Negligible.
Requests [Per Hour] |
Nginx FS Stats |
Nginx FS Reads |
Apache FD Stats |
Apache FS Reads |
Comment |
1 |
1 |
1 |
6 |
4 |
Single Request [pretty much no load] |
10 |
10 |
10 |
60 |
40 |
Ten requests [pretty much no load] |
3,600 |
3,600 |
3,600 |
21,600 |
14,400 |
1 req/sec [Very Low load] |
144,000 |
144,000 |
144,000 |
864,000 |
576,000 |
req/sec [Moderate traffic-nothing very large] |
324,000 |
324,000 |
324,000 |
1,944,00 |
1,296,000 |
req/sec [higher traffic site-not massive] |
576,000 |
576,000 |
576,000 |
3,456,000 |
2,304,000 |
req/sec [Pretty high Traffic-still not massive though] |
More Numbers
The default for Apache are to use allowoverride all. Let's look at the this for a Drupal website. One image for the theme. If you ' re website docroot are At/var/www/drupal6/then We just added more file system stats. This adds 3 stats per request. This was an incredibly common apache/drupal setup. It ' s The end result of countless guides out there.
/var/www/drupal6/sites/example.com/themes/yourtheme/images/layout/header.png
htaccess files would be is in this path unless you create your own. I ' ll be assuming added one in/var/www/because the is common.
Requests [Per Hour] |
Nginx FS Stats |
Nginx FS Reads |
Apache FD Stats |
Apache FS Reads |
Comment |
144,000 |
144,000 |
144,000 |
1,296,000 |
576,000 |
Req/sec |
324,000 |
324,000 |
324,000 |
2,916,000 |
1,296,000 |
Req/sec |
576,000 |
576,000 |
576,000 |
51,840,000 |
2,304,000 |
Req/sec |
Conclusion
Stop using. htaccess. It ' s horrible for performance. Nginx is designed to be efficient. Adding something like this would destroy.