我正在尝试使用Nginx建立一个Wiki。
当我使用/wiki/File:image.jpg
Nginx时返回404。
当我使用/index.php?title=File:image.jpg
它时,它可以正常工作。
server {
listen 80;
listen [::]:80 ipv6only=on;
root /usr/share/nginx/mediawiki;
index index.php index.html index.htm;
...
location /wiki/ {
index index.php;
rewrite ^/wiki/([^?]*)(?:\?(.*))? /index.php?title=$1&$2 last;
}
location ~* /wiki/images/.*.(html|htm|shtml|php)$ {
types { }
default_type text/plain;
}
location ~* /wikiimages/ {
try_files $uri /wiki/index.php;
}
location ~* \.(js|css|jpg|jpeg|png|gif|ico)$ {
try_files $uri /wiki/index.php;
expires max;
log_not_found off;
}
location ~*\.php?$ {
try_files $uri =404;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
include fastcgi_params;
}
location /wiki/.*\.php?$ {
try_files $uri =404;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
include fastcgi_params;
}
}
我更改了试图直接提供静态资源的正则表达式。
server {
...
location ~* \.(js|css|gif|ico)$ {
try_files $uri /wiki/index.php;
expires max;
log_not_found off;
}
...
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句