2017-03-18 57 views
0

我的網站使用IP打開,但我需要將IP重定向到域。如何在.htaccess中將IP重定向到https://域

我使用Laravel框架創建項目。

我的服務器是Ubuntu的16.04

我的.htaccess是://這個文件是根文件夾

<IfModule mod_rewrite.c> 
    RewriteEngine on 
    RewriteBase/

    RewriteCond  %{SERVER_PORT} ^80$ 
    RewriteRule  ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R] 

    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] 
    RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,QSA,NC,L] 

    RewriteCond %{HTTPS_HOST} ^10\.10\.10\.10 
    RewriteRule (.*) https://website.com/$1 [R=301,L] 
</IfModule> 

但這並不代碼和我一起工作。

謝謝

+0

嗨@anubhava,現在,我可以打開網站,IP,這個IP沒有重定向到https://域名。 – mySun

+0

檢查您的訪問日誌並查看即將到來的確切請求 – anubhava

回答

0

有這樣說:

RewriteEngine on 
RewriteBase/

RewriteCond %{HTTPS_HOST} !^website\.com$ [NC] 
RewriteRule^https://website.com%{REQUEST_URI} [R=301,L,NE] 

RewriteCond %{HTTPS} off [OR] 
RewriteCond %{HTTP_HOST} ^www\. [NC] 
RewriteRule^https://website.com%{REQUEST_URI} [L,R=301,NE]