2016-12-16 127 views
1

請幫助.htaccess將根目錄和index.php重定向到https根目錄

如何將HTTP根目錄和index.php重定向到HTTPS根目錄。 樣式和腳本與index.php相同。

RewriteEngine On 

RewriteRule ^(.*)/$ /$1 [L,R=301] 

# Handle Front Controller... 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule^index.php [L] 

謝謝!

+1

的可能的複製[htaccess的重定向到https:// WWW(http://stackoverflow.com/questions/13977851/htaccess-redirect-to-https-www ) – JazZ

回答

0

的一種方法是:

RewriteCond %{HTTPS} off 
# First rewrite to HTTPS: 
# Don't put www. here. If it is already there it will be    included, if not 
# the subsequent rule will catch it. 
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
# Now, rewrite any request to the wrong domain to use www. 
RewriteCond %{HTTP_HOST} !^www\. 
RewriteRule .* https://www.%{HTTP_HOST}%. {REQUEST_URI} [L,R=301] 
相關問題