Htaccess rewrite file for Letsencrypt and CakePHP app


/ Published in: Apache

This .htaccess actually forces all traffic to https, and allows cakephp app to work properly, as well as letsencrypt to go thru


Copy this code and paste it in your HTML
  1. <IfModule mod_rewrite.c>
  2. RewriteEngine on
  3.  
  4. RewriteRule ^.well-known/ - [L,NC]
  5.  
  6. RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
  7. RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
  8.  
  9. RewriteCond %{HTTPS} !=on
  10. RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
  11.  
  12. RewriteRule ^$ app/webroot/ [L]
  13. RewriteRule (.*) app/webroot/$1 [L]
  14. </IfModule>

URL: https://stackoverflow.com/questions/38790421/letsencrypt-with-htaccess/41391957#41391957

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.