R
R
Ruslan Tilyaev2020-04-29 13:18:35
htaccess
Ruslan Tilyaev, 2020-04-29 13:18:35

How to set up a redirect from http to https?

Hello, I made a redirect to https, inserted the code into the .htaccess file

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>


All pages are protected, except for the main one. What is the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2020-04-29
@shambler81

IfModule mod_rewrite.c can be omitted as it is enabled by default.
just do not forget that it should be up to the cnc site, give me the whole file.
on some servers the redirect is caught differently,
somewhere
RewriteCond %{HTTPS} off works
somewhere
RewriteCond %{HTTPS} !on
in general, just pick a redirect that suits your server.
There are 30 of them
. There are also on Habré.
Here is an example

RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

How to set up a redirect to https in .htaccess?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question