我尝试将点击我页面的所有请求重定向到图片。在我的default.conf里面我有这个:
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
try_files $uri $uri/ /usr/share/nginx/html/10343632.jpeg;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
jpeg文件是图像,它位于/ usr / share / nginx / html中,我已从该目录中删除了所有其他文件。每次我点击页面时都会给出:
rewrite or internal redirection cycle while internally redirecting to "/usr/share/nginx/html/10343632.jpeg
我也尝试过:
try_files $uri /usr/share/nginx/html/10343632.jpeg;
和
try_files $uri /10343632.jpeg;
并得到了同样的错误。无论用户请求什么,这都是为了提供图像。
答案 0 :(得分:0)
位置部分必须考虑root用户:
location / {
root /usr/share/nginx/html/;
try_files $uri /10343632.jpeg;
}
它会起作用!