2017-06-01 50 views
1

我最近添加了ssl並希望重定向到https,但是到了子文件夾。如何重定向到根目錄,但使用https

我應該如何修改我的重定向爲https而不僅僅是http?

這是我目前在.htaccess文件

RewriteEngine on 
RewriteCond %{HTTP_HOST} main\.com [NC] 
RewriteCond %{REQUEST_URI} ^/$ 
RewriteRule ^(.*)$ /directory/$1 [L] 

回答

0

您需要http -> https其他重定向規則的重寫規則之前:

RewriteEngine on 

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

RewriteCond %{HTTP_HOST} main\.com [NC] 
RewriteCond %{REQUEST_URI} ^/$ 
RewriteRule ^(.*)$ /directory/$1 [L] 
+1

現在有道理。謝謝 – user2300867

相關問題