[英]Jquery Ajax request works in http but fails over https (error 404)
我有一個LAMP測試服務器(Apache 2.4.25),為了測試http2,我使用自簽名證書配置了SSL。 除了Jquery Ajax請求完全可以在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]
從服務器添加Access-Control-Allow-Origin標頭
Access-Control-Allow-Origin: (your website url)
它對我有用,我希望它也對您有用。
好的,我發現與apache conf有關的問題,我錯過了指令
AllowOverride All
在此部分中,對不起,謝謝您的幫助!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.