美文网首页
php解决ajax跨域

php解决ajax跨域

作者: geeooooz | 来源:发表于2019-04-10 11:26 被阅读0次

    PHP后台配置
    PHP后台得配置几乎是所有后台中最为简单的,遵循如下步骤即可:

    第一步:配置Php 后台允许跨域

    <?php
    header('Access-Control-Allow-Origin: *');
    header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
    //主要为跨域CORS配置的两大基本信息,Origin和headers
    

    第二步:配置Apache web服务器跨域(httpd.conf中)

    原始代码

    <Directory />
        AllowOverride none
        Require all denied
    </Directory>
    

    改为以下代码

    <Directory />
        Options FollowSymLinks
        AllowOverride none
        Order deny,allow
        Allow from all
    </Directory>
    

    相关文章

      网友评论

          本文标题:php解决ajax跨域

          本文链接:https://www.haomeiwen.com/subject/xcfniqtx.html