Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery Ajax请求在http中工作,但在https上失败(错误404)_Jquery_Ajax_Apache_Codeigniter_Https - Fatal编程技术网

Jquery Ajax请求在http中工作,但在https上失败(错误404)

Jquery Ajax请求在http中工作,但在https上失败(错误404),jquery,ajax,apache,codeigniter,https,Jquery,Ajax,Apache,Codeigniter,Https,我得到了一个LAMP测试服务器Apache2.4.25,为了测试http2,我用自签名证书配置了SSL。除了jqueryajax请求,其他一切都可以正常工作,jqueryajax请求可以在http上完美工作,但是现在在https上它返回一个错误404 php框架背后是codeIgniter 是否是自签名证书导致了问题? 是否将其视为跨域请求 下面是ajax代码 //récup initiale des infos du panier de sélection $.ajax({

我得到了一个LAMP测试服务器Apache2.4.25,为了测试http2,我用自签名证书配置了SSL。除了jqueryajax请求,其他一切都可以正常工作,jqueryajax请求可以在http上完美工作,但是现在在https上它返回一个错误404

php框架背后是codeIgniter

是否是自签名证书导致了问题? 是否将其视为跨域请求

下面是ajax代码

//récup initiale des infos du panier de sélection
    $.ajax({
        url: base_url + 'ajax_selection/getNumItems/',
        type: 'POST',
        // csrf protection
        data: {'<?php echo $this->security->get_csrf_token_name(); ?>': '<?php echo $this->security->get_csrf_hash(); ?>'},
        datatype: 'json',
        error: function (jqXHR, textStatus, errorThrown) {
            if (textStatus === 'timeout') {
                alert("Problème de connexion : Vérifiez votre connexion internet");
            } else {
                throw "errorThrown : " + errorThrown + " | textStatus : " + textStatus + " | Error : AjaxContent has not a valid path";
            }
        },
        success: function (data, jqXHR, textStatus) {
            // notification de l'ajout à la liste de sélection
            //console.log('selected Item '+data);//test ok
            $('.link-selection').html(data);
        }
    });
我如何处理这个问题

谢谢你的帮助

[编辑] 这是入口

#   Toutes les autres URL vont être redirigées vers le fichier index.php.
#RewriteRule blog$ wp/index.php
#RewriteRule ^(.*)$ index.php/$1 [L]
<IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteCond %{ENV:REDIRECT_STATUS} ^$
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

# Redirection permanente des pages formation-motcle-annee vers /formation/motcle/annee
RewriteRule ^formations-([a-z]+)-([0-9]+).html  /formations/$1/$2 [L,R=301]
RewriteRule ^formations-([a-z]+).html  /formations/$1/$2 [L,R=301]

#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php?/$1 [L]

从服务器添加Access Control Allow Origin标头

Access-Control-Allow-Origin: (your website url)

它对我有效,我希望它对您也有效。

好的,我发现了与apache conf相关的问题,我错过了指令

AllowOverride All

在本节中,抱歉&感谢您的帮助

谢谢,我在virtualHost conf:Header set Access Control Allow Origin*中尝试了这个方法,但它不起作用。您可以共享您的ajax代码以便我可以帮助您吗?当您从浏览器调用此请求时,请检查您的JavaScript控制台,它应该向您显示哪些非SSL链接导致它断开http://yes,尝试使用ssl加载此文件,如:而不是505内部服务器错误。