Y
Y
Yuri Dmitriev2018-11-15 16:15:48
Apache HTTP Server
Yuri Dmitriev, 2018-11-15 16:15:48

How to set up an http to https redirect?

Options +FollowSymlinks
Options -Indexes
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*) index.php [QSA,L]

RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteCond %{REMOTE_HOST} !^xxx\.xxx\.xxx\.xxx

I can't figure out how to set up a redirect from http to https

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey, 2018-11-25
@BonifacyBel

RewriteCond %{REMOTE_HOST} !^xxx\.xxx\.xxx\.xxx - what is this? Tipo so that if you enter by IP was a redirect to the domain?
Try like this:

RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

Or:
RewriteCond %{HTTP_HOST} !^mysite.ru$ [NC]
RewriteRule ^(.*)$ https://mysite.ru/$1 [L,R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question