2017-08-12 101 views
0

我想修改我的.htacess文件来强制https,但因为我已经有一些规则,我似乎打破了它。任何人都可以帮助建议我吗?htaccess文件重定向到强制https

DirectoryIndex index.php 
RewriteEngine on 

RewriteCond $1 !^(index\.php| (.*)\.swf|forums|images|css|downloads|jquery|js|robots\.txt|favicon\.ico) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA] 
+0

可能重复[htaccess重定向到https:// www](https://stackoverflow.com/questions/13977851/htaccess-redirect-to-https-www) – localheinz

回答

0

我这样做:

RewriteCond %{HTTPS} off 
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 
+0

太棒了,谢谢 – Trotterwatch

0

使用RewriteEngine叙述。这将强制ssl。

RewriteEngine On 
RewriteCond %{HTTP_HOST} !^$ 
RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteCond %{HTTPS}s ^on(s)| 
RewriteRule^http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 
+0

不客气。如果您使用了答案,请标记为已接受。 – Goldbug

1

你可以试试:

您还可以检查此link出来。你可能需要很多其他规则。