A
A
ADamCarraway2022-01-04 19:27:53
htaccess
ADamCarraway, 2022-01-04 19:27:53

What needs to be written in htaccess to redirect to https?

I use vps server reg.ru. According to the guide, I set up ssl on the server and the end says

After installing SSL, set up a redirect from HTTP to HTTPS. The redirect for Apache is configured through the .htaccess file.

It is written what needs to be added to the end of the htaccess file
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI } [R=301,L]

Here is the htaccess I had (at the root of the project)
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule ((?s).*) public/$1 [L]

Then I wrote
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule ((?s).*) public/$1 [L]
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

But after that I go to the site. I see https in the address bar, but the browser says that it is not possible to connect securely.
What am I doing wrong? What should htaccess look like?
I searched on the Internet but nothing helped. Tried like this
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^(.*)$ public/$1 [L]
    RewriteCond %{HTTPS} !=on
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} !^public [L,R=301]
</IfModule>

doesn't work either

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyacheslav Plisko, 2022-01-05
@AmdY

Then just don't scold the framework when your data is stolen or hacked. Apache and dumping code into a root document - how is it possible in 2022?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question