-
-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
Hi, it will be better to replace this nginx conf with one that only use try_files directive.
Lines 102 to 107 in fbc7b95
| location / { | |
| if (!-e $request_filename){ | |
| rewrite ^/(.*)$ /index.php?doc=$1 last; | |
| } | |
| try_files $uri $uri/ =404; | |
| } |
In the above example =404 its never used, because the rewrite rule prevent that. This is a better aproach:
location / {
try_files $uri $uri/ @wikidocsrw;
}
location @wikidocsrw {
rewrite ^/(.*)$ /index.php?doc=$1 last;
}
So everytime something will end up on 404 it will be handled by the @wikidocsrw location.
Also, this is a example to serve WikiDocs on a subdirectory using nginx:
# wikidocs
location / {
return 301 /wikidocs;
}
location ~* /wikidocs/(.+)\.(css|gif|ico|jpg|jpeg|js|png|svg)$ {
try_files $uri =404;
add_header Cache-Control "public, max-age=3600";
}
location ~* /wikidocs/(.+)\.md$ {
return 301 /wikidocs;
}
location = /wikidocs/datasets/config.inc.php {
deny all;
}
location /wikidocs {
index /wikidocs/index.php;
try_files $uri $uri/ @wikidocsrw;
}
location @wikidocsrw {
rewrite ^/wikidocs/(.*)$ /wikidocs/index.php?doc=$1 last;
}
location ~ /wikidocs/(.+)\.php$ {
fastcgi_index /wikidocs/index.php;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_intercept_errors on;
include fastcgi.conf;
}
I hope it helps.
robsonsobral
Metadata
Metadata
Assignees
Labels
No labels