我有一个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]
2条答案
按热度按时间x6h2sr281#
好的,我发现了问题,它与Apache配置有关,我错过了指令
在本节中,对不起&谢谢你的帮助!
w8biq8rn2#
从服务器添加Access-Control-Allow-Origin标头
这对我很有效,我希望对你也一样。