Issue
I have a cakephp3 website and a wordpress website. in the root folder the .htaccess rewrites wordpress http commands to https . However I also need my cakephp3 to redirect http to https . I cant do this for cakephp3. The SSL is set up. The below doesnt work as it redirects a https wrongly
# 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
I have looked at other websites like
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
Solution
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]
Hope this helps.
Answered By - Orhan Esin
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.