Apache .htaccess syntax to nginx - Simple convert question
I have a folder which is /generator/data … The data folder has 777 permissions and inside the data folder i have a .htaccess file with thw following syntax:
order deny,allow
deny from all
<files ~="" "\.(txt|html|gz)$"="">allow from all</files>
This .htaccess rule blocks access to the /generator/data for everyone EXCEPT for files with extensions .txt , .html , .gz ….
The problem is i am using NGINX as my Webserver and not Apache. I know that i have to update somehow my Virtual Host file for my domain. Can someone help me to convert this simple Apache rule into NGINX syntax???
Thanks in advance
George
3 Replies
location ~* ^/generator/data/(.*)\.(txt|html|gz)$ {
allow all;
}
location /generator/data {
deny all;
}
The ordering of location directives is important, you can read about this here
@melon:
The ordering of location directives is important, you can read about this
here
Thank you very much for your help. What do you mean with "The ordering of location directives is important"???
Thanks
George
To summarize, the order in which directives are checked is as follows:
Directives with the "=" prefix that match the query exactly. If found, searching stops.
All remaining directives with conventional strings. If this match used the "^~" prefix, searching stops.
Regular expressions, in the order they are defined in the configuration file.
If #3 yielded a match, that result is used. Otherwise, the match from #2 is used.