An htaccess file that redirects my advanced Yii2 application to the frontend index.php file so that there is already a .htaccess file. which has the following lines.
It is now right now .HTACCESS in the root directory
Options -Indexes <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_URI} !^public RewriteRule ^(.*)$ frontend/web/$1 [L] </IfModule> # Deny accessing below extensions <Files ~ "(.json|.lock|.git)"> Order allow,deny Deny from all </Files> # Deny accessing dot files RewriteRule (^\.|/\.) - [F]
now i searched the internet and i found this if i want to redirect to https then i have to add this.
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
so I added like this ....
Options -Indexes <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} RewriteCond %{REQUEST_URI} !^public RewriteRule ^(.*)$ frontend/web/$1 [L] </IfModule> # Deny accessing below extensions <Files ~ "(.json|.lock|.git)"> Order allow,deny Deny from all </Files> # Deny accessing dot files RewriteRule (^\.|/\.) - [F]
then it loads the website using any js and css ... and is also in http. But the content that it requires must be in https.
I understand that this is because of my other rewrite statement. But I'm not so good at it. Please make an offer.
Here this thing, if it is one, works fine without any problems.
RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
He will send my http to https. So it works.
Or if this is one
RewriteCond %{REQUEST_URI} !^public RewriteRule ^(.*)$ frontend/web/$1 [L]
This rule reports that execute the index.php file from the [.htaccess Directory / frontend / web /] directory. The tool runs the /web/index.php interface. It is very important to do this here, since it corresponds to the structure of the structure.
So, I need to combine these two rules together and create a .htaccess that will work for both scenarios.
Conclusion
So, my .HTACESS should tell the server that we should run [.HTACESS DIR / frontend / web / index.php] in https.
UPDATE TO QUESTION
this is .htaccess in the interface / web / folder where my index.php is
And this is in the root / frontend / web folder where index.php exists.
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php
Do I need to add https here?