我想将请求重定向到index.php以启用漂亮的链接,使用try_files可以实现此目的,但是我似乎无法让try_files和add_headers同时工作
我当前的位置块如下所示:
location /api/v1/ {
try_files $uri /sephaku/api/v1/index.php?$query_string;
add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken';
add_header 'Access-Control-Allow-Origin' 'http://0.0.0.0:9000';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'Authorization';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
但标题似乎没有添加。
我尝试添加一个 if 语句,如下所示:
if ($request_method = 'GET') { }
我的标题在里面。在这种情况下,标头起作用,但重定向不起作用。