www.miinik.com - 域名
www.jingjingna.com - 子域名
我已经尝试了大部分 htaccess 代码来强制使用 SSL,但它一直导致重定向循环。所以我从互联网上得到了这段代码,通过插件应用了它,哇!它现在完美地工作......对于 miinik.com。可悲的是,我登录了 jingjingna.com,现在 miinik.com 的所有设置都应用到了 jingjingna.com(它应该是一个完全不同的站点)。问题可能来自 php 代码或 htaccess(miinik.com) *PS 我没有编辑jingjingna htaccess
<?php
if (stripos(get_option('siteurl'), 'https://') === 0) {
$_SERVER['HTTPS'] = 'on';
// add JavaScript detection of page protocol, and pray!
add_action('wp_print_scripts', 'force_ssl_url_scheme_script');
}
function force_ssl_url_scheme_script() {
?>
<script>
if (document.location.protocol != "https:") {
document.location = document.URL.replace(/^http:/i, "https:");
}
</script>
<?php
}
--------------------miinik htaccess------------------------ ------
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
最佳答案
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://wwww.miinik.com%{REQUEST_URI} [R,L]
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://www.jingjingna.com%{REQUEST_URI} [R,L]
好了,域上只有 2 个不同的 .htaccess 文件。
关于php - 强制 SSL 服务器和子域崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28780350/