-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnginx.conf
45 lines (39 loc) · 1.08 KB
/
nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
location / {
# If the requested URL is a directory
if (-d $request_filename) {
# And if the directory does not contain an index file
set $no_index 1;
if (-f $request_filename/index.php) {
set $no_index 0;
}
if (-f $request_filename/index.html) {
set $no_index 0;
}
if (-f $request_filename/index.htm) {
set $no_index 0;
}
if (-f $request_filename/index.cgi) {
set $no_index 0;
}
if (-f $request_filename/index.shtml) {
set $no_index 0;
}
# Then return a 403 Forbidden error
if ($no_index) {
return 403;
}
}
# If the requested URL is not a file
if (!-f $request_filename) {
# Then rewrite the URL to index.php
rewrite ^(.*)$ /index.php?$query_string last;
}
# Hide files and folders starting with a dot
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
# Serve the requested file
try_files $uri $uri/ =404;
}