Javascript 使用htaccess重定向到https
我使用.htaccess从http重定向到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和
<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]