Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.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
Javascript 使用htaccess重定向到https_Javascript_Php_Css_Apache_.htaccess - Fatal编程技术网

Javascript 使用htaccess重定向到https

Javascript 使用htaccess重定向到https,javascript,php,css,apache,.htaccess,Javascript,Php,Css,Apache,.htaccess,我使用.htaccess从http重定向到https。 但是页面没有完全成功加载,因为我使用了下面的脚本来加载外部文件 <script src = "http://domain.com/ajax/libs/jquery/1.7.1/jquery.min.js"> </script> <link rel = "stylesheet" type = "text / css" href = "http://domain.com/file.css"> 不要在src和

我使用.htaccess从http重定向到https。 但是页面没有完全成功加载,因为我使用了下面的脚本来加载外部文件

<script src = "http://domain.com/ajax/libs/jquery/1.7.1/jquery.min.js"> </script>
<link rel = "stylesheet" type = "text / css" href = "http://domain.com/file.css">

不要在src和href标记中包含协议。如果这样做,它将无法工作,因为它将尝试加载http,而浏览器将阻止它。您需要将其更改为非协议特定路径或更改为https。@PanamaJack是正确的-加载您的JS、CSS和所有其他资产而不使用协议特定路径,或者您可以根据活动路径进行加载:例如-
RewriteEngine On
RewriteBase /
RewriteCond% {HTTP_HOST} ^ www \. (. *) $ [NC]
RewriteRule ^ (. *) $ Http: //% 1 / $ 1 [R = 301, L]

<IfModule mod_rewrite.c>

RewriteCond% {HTTPS} off
RewriteRule (. *) Https: //% {HTTP_HOST}% {REQUEST_URI} [R, L]

</ IfModule>
RewriteCond% {HTTPS} off
RewriteRule (. *) Https: //% {HTTP_HOST}% {REQUEST_URI} [R, L]