阅读:3994回复:4
请教下ANK下N模式里配置虚拟目录问题
本地架设discuzX3.3论坛时,想将附件目录单独存放在另一分区,与论坛主程分离。
在配置文件中,添加 location /data/attachment/ { alias f:/attachment/; } 无法访问,返回404,换成 location /data/attachment/ { root f:/attachment/; } 也无法访问。百度了一下,看到有个提法是 不能用windows路径,要用 /cygdrive/f/attachment/ ,但测试后还是404,求指点。 |
|
|
沙发#
发布于:2018-03-30 09:16
你的f:/data/attachment/目录路径应该是真实存在的,然后alias和root用法如下(用一种即可):
location /attachment/ { alias f:/data/attachment/; } location /attachment/ { root f:/data; } 重启nginx 放一张123.jpg图片于f:/data/attachment/目录下,http://域名/attachment/123.jpg验证成功与否。 |
|
板凳#
发布于:2018-03-30 09:37
不好意思,有点差错!!
真实路径是f:/attachment/,想设置为虚拟路径 /data/attachment/ |
|
|
地板#
发布于:2018-03-30 09:46
server {
listen *:80; server_name 192.168.0.100 ; root "F:/webroot/vhost8"; index index.html index.htm index.php default.php app.php u.php; autoindex off; sub_filter 'http://$host:443' '$scheme://$host'; sub_filter 'http:\/\/$host:443' '$scheme://$host'; sub_filter 'http://$host:8011' '$scheme://$host'; sub_filter 'http://$host:8033' '$scheme://$host'; sub_filter 'http://$host:80' '$scheme://$host'; sub_filter_once off; sub_filter_types text/css text/xml text/plain application/json application/javascript application/xml application/rss+xml application/xhtml+xml; location ~ /\.(htaccess|uini)$ { deny all; } location /attachment/ { alias f:/data/attachment/; } include gzip.conf; location ~* .*\/(attachment|attachments|uploadfiles|avatar)\/.*\.(php|phps|php5|php7|fcgi|jsp|jspx|asp|aspx|asa|asax|ascx|ashx|asmx|axd)$ { deny all; } location ~ \.php$ { proxy_pass http://bakend_php; include uproxy.conf; } try_files $uri @proxy; location @proxy { internal; proxy_pass http://bakend_php; include uproxy.conf; } rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last; rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last; rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last; rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last; rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last; rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last; rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last; rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last; rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last; if (!-e $request_filename) { return 404; } } |
|
|
4楼#
发布于:2018-03-30 15:34
已经解决,是最后这段 伪静态代码的问题
if (!-e $request_filename) { return 404; } 去除后就正常了!! |
|
|