手记

php、apache、nginx解决跨域问题

  1. apache:
    a. 首先确保加载了mod_headers模块:LoadModule headers_module modules/mod_headers.so
    b. 在配置文件中加上:Header set Access-Control-Allow-Origin *

  2. nginx:
    在配置文件中加上:add_header 'Access-Control-Allow-Origin' "$http_origin";

  3. php:
    在入口文件中加上:header('Access-Control-Allow-Origin: *');

0人推荐
随时随地看视频
慕课网APP