用于2个网站的SSL的htaccess

时间:2017-11-19 01:00:52

标签: .htaccess cakephp

我有一个cakephp3网站和一个wordpress网站。在根文件夹中,.htaccess将wordpress http命令重写为https。但是我还需要我的cakephp3将http重定向到https。我不能为cakephp3这样做。 SSL已设置完毕。以下不起作用,因为它错误地重定向https

# BEGIN SSL
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://crm.mydomain/$1 [R=301,L]  //cakephp3
RewriteRule ^(.*)$ https://www.mydomain//$1 [R=301,L]  //wordpress
# END SSL

我看过其他网站,比如

https://stackoverflow.com/questions/46958423/cakephp3-prevent-route-to-wordpress-blog-by-htaccess
http://www.inmotionhosting.com/support/website/ssl/how-to-force-https-using-the-htaccess-file

1 个答案:

答案 0 :(得分:0)

RewriteEngine on
Rewritebase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

希望这有帮助。