Hello guys I am using slim 3 framework and I use the default htaccess file on slim documentation so when a request come to my server it will be passed to index.php which will make use of the router to render a specific view
now my question is how to make use of my https with keep using this method
I found this in stackoverflow
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
but if I use it then the router won’t work properly cause this will disturb it
please help
Is not a “slim” topic, anyway you can use an .htaccess for archive it:
let me know if is not working
### Activate the rewrite rule engine
RewriteEngine on
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
1 Like
Yes I know it could be accomplished using an htaccess file the problem is I already have an htaccess file that contains the following
Options -Indexes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
This htaccess file will pass any url to index.php file so I can use my slim router how to keep using the slim router along with https this is my question.
Hope you get what I mean , thanks in advance.
But it doesn’t have any effect using https or https on slim router.
So i don’t understand what’s your problem.
1 Like
yes I know this to be more specific I don’t know what these line of code does I used the htaccess file on slim docs but I don’t know exactly how it works.
what I mean about it will disturb my router if it type this in my url myurl/about-us the about us will be passed to index.php which will have a similar route to redirect the user for in the file you give me you removed the
RewriteRule ^ index.php [QSA,L]
so how would the request be passed to the index.php then