首页 > 问答 > 正文
1
2
3
4
5
6
7
8
9
10
<code>location ~ /(test1|test2|test3|test4) {
proxy_set_header Host "test.com";
proxy_set_header Host
"test.com"
;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-For
$remote_addr
proxy_pass http://127.0.0.1;
proxy_pass http:
//127.0.0.1;
}
if ($request_filename !~* ^/(.*)\.(zip|js|ico|css|php|xml|txt|html|swf|apk|ipa|plist)$) {
if
(
$request_filename
!~* ^/(.*)\.(zip|js|ico|css|php|xml|txt|html|swf|apk|ipa|plist)$) {
rewrite ^/(.*)$ /index.php last;
</code>
上面proxy规则不会生效,如果删掉rewrite规则就可以,应该是冲突了?改如何修改?
高洛峰2017-05-16 17:28:41
rewrite 优先级较高,导致路径已经先被重写了。可以都改用location去匹配。
rewrite
location
11
12
13
14
15
16
17
18
19
<code> location ~ /(test1|test2|test3|test4) {
proxy_pass http://127.0.0.1:8080;
//127.0.0.1:8080;
location ~* ^/(.*)\.(zip|js|ico|css|xml|txt|html|swf|apk|ipa|plist)$ {
location ~ \index.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_pass unix:/
var
/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME
$document_root
$fastcgi_script_name
include fastcgi_params;
include
fastcgi_params;
fastcgi_hide_header X-Powered-By;
不过确定 静态文件也要重写到 index.php吗?
index.php