PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, January 19, 2022

[FIXED] htaccess for SSL for 2 websites

 January 19, 2022     .htaccess, cakephp     No comments   

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
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing