php - 强制 SSL 服务器和子域崩溃

标签 php .htaccess ssl crash server

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/

相关文章:

php - 如果内存过度使用,哪个进程会被内核杀死? child 还是 parent ?

PHP mySQL Htaccess 漂亮的链接

android - 如何在 Android 上正确配置 CharlesProxy

ssl - PayPal 网站支付专业版 TLS

php - 为什么需要MINUTE才能从服务器获得响应?

php - 为什么我不能在我的代码中结合使用 javascript 和 php?

php - 如何在 Mac OSX 上安装 Ratchet?

php - 如何使用 htaccess 在特定文件夹中禁用 auto_prepend?

Apache RewriteMap 用于防止直接访问文件

ssl - 骡子 ESB 3.4.x : Multiple https clients with client certificate doesn't work togheter