![](/img/trans.png)
[英]Using .htaccess, How to force HTTPS without conflicting with other RewriteRules?
[英]How to force HTTPS without using .htaccess file in cPanel
最近,我安裝了SSL。 它工作正常,但是我的網站沒有重定向到https。 我的服務器不支持htaccess文件。 還有其他方法嗎?
提前致謝。
嘗試一次此技巧。 我不確定它是否正確。 試試看,讓我知道。
<?php
if ( $_SERVER['HTTPS'] == "" )
{
header("HTTP/1.1 301 Moved Permanently");
header('Location: https://yoursite.com.php');
}
?>
現在,您可以執行您的httpd.conf文件或指定了虛擬主機的文件,並添加以下行以將http重定向到https:
<virtualhost *:80="">
ServerName mysite.com
ServerAlias www.mysite.com
Redirect / https://<your site name>/
DocumentRoot /var/www/public_html
</virtualhost>
你可以在if條件下使用
$_SERVER[REQUEST_SCHEME]!='https'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.