2017-06-01 60 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

相关问题