apache jQuery AJAX 请求在http中工作,但在https上失败(错误404)

3zwtqj6y  于 2023-02-24  发布在  Apache
关注(0)|答案(2)|浏览(229)

我有一个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);
        }
    });

我该如何处理这个问题?
谢谢你的帮忙
[编辑]这里是htaccess

#   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]
x6h2sr28

x6h2sr281#

好的,我发现了问题,它与Apache配置有关,我错过了指令

AllowOverride All

在本节中,对不起&谢谢你的帮助!

w8biq8rn

w8biq8rn2#

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

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

这对我很有效,我希望对你也一样。

相关问题