Skip to content
Matej Jellus edited this page Oct 9, 2019 · 1 revision

Links:

PHP and Slim Framework

For some project I am using slim and it has its index.php in the root path of the project, which is not a good practice. Mostly you want to have it in some public directory. To accomplish this and in the same time solve http -> https redirect problem, I am using this:

# /.htaccess
<IfModule mod_rewrite.c>
   RewriteEngine on

   RewriteCond %{HTTP:X-Forwarded-Proto} !=https
   RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
   RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
   RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

   RewriteCond %{REQUEST_URI} !public/
   RewriteRule (.*) /public/$1 [L]
</IfModule>
Clone this wiki locally