首頁  >  文章  >  後端開發  >  nginx 設定ajax跨域存取php api

nginx 設定ajax跨域存取php api

WBOY
WBOY原創
2016-08-08 09:32:551507瀏覽

開啟nginx的設定檔nginx.conf,在server中設定一下:

location ~ .php?($|/)

{
#try_files $uri =404;
#handel cosr    by mao
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'OPTION, POST, GET';
                                                中之後 'Access-Control-Allow-Headers' 'X-Requested-With, Content-Type';
fastcgi_pass  unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;

}



以上就介紹了nginx 設定ajax跨網域存取php api,包含了方面的內容,希望對PHP教學有興趣的朋友有幫助。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
上一篇:PHP 使用redis下一篇:PHP 使用redis