2016-09-18 73 views
0

我正在尝试将所有请求都打到我的页面上。在我的default.conf我有这样的:使用nginx将所有请求重定向到静态页面

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 /共享/ 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

所在地段必须考虑根这样的:

location/{ 
    root /usr/share/nginx/html/; 
    try_files $uri /10343632.jpeg; 
} 

,它会努力!

相关问题