2016-09-18 10 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/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

場所のセクションには、そのルートを考慮する必要があります。

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

し、それがうまくいきます!

関連する問題