call domain.com/index.php failed
SaeedPoureshghi opened this issue · 3 comments
I want o redirect all http to https requests when i edit .htaccess file :
RewriteRule ^(.*)$ https://mydomain.com/index.php [QSA,L]
it not working , because when i call mydomain.com/index.php its failed!.
i think index.php
proccess as a route!
Hey @saeedIT ,
this is not a problem with the router. This is because you want to solve many problems in one single line. Try to isolate the https rediret from the index.php rewrite like in this file (Not tested):
DirectoryIndex index.php
# enable apache rewrite engine
RewriteEngine on
# set your rewrite base
# Edit this in your init method too if you script lives in a subfolder
RewriteBase /
# Redirect to https
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Deliver the folder or file directly if it exists on the server
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Push every request to index.php
RewriteRule ^(.*)$ index.php [QSA]
This is because the webserver will now send a 301 Redirect back to the browser. The bowser will then connect to the new https verion of the webpage. In this second request the server will jump over the https rule because the request is already https and will then rewrite to the index.php
You cannot do a rewrite and a redirect in one line. Because the browser has to reconnect to the server after a redirect.
I think, this issue was solved.