我应该写这样的东西
location !-f { proxy_pass http://lst207.b.ls1.ru:8000/; } # static content location ~* ^.+\.(jpg|jpeg|gif|css|js|ico|rar|gz|zip|pdf|tar|bmp|xls|doc|swf|mp3|avi|png|htc|txt|htc|flv)$ { #root "$document_root$"; access_log off; expires 7d; }
但似乎“-f”标志不起作用
try_files专为此场景而devise。
location / { try_files $uri $uri/ @fallback; } location ~* \.(jpg|jpeg|gif|css|js|ico|rar|gz|zip|pdf|tar|bmp|xls|doc|swf|mp3|avi|png|htc|txt|htc|flv)$ { access_log off; expires 7d; } location @fallback { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://lst207.b.ls1.ru:8000/; }
如果index.php的第一行(在注释中)是: header("HTTP/1.0 302 Found"); 那么它应该发送一个302而不是一个404到浏览器,但我想在Apache的条款,而不是nginx。
第二行可能是这样的: header("Location: <redirect location>");
可能够了吗?
location ~* ^.+.(jpg|jpeg|gif|css|js|ico|rar|gz|zip|pdf|tar|bmp|xls|doc|swf|mp3|avi|png|htc|txt|htc|flv)$ { root /the/location/of/static; access_log off; expires 7d; } location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://lst207.b.ls1.ru:8000/; }
这是否适合你?