I
I
Ivanus2016-05-08 18:09:20
Apache HTTP Server
Ivanus, 2016-05-08 18:09:20

How to redirect from http to https with original url?

There was a problem when there was no ssl, it worked like this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]

After installing the certificate, I had to redirect from http to https:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

At the same time, if without a redirect, then the domain.ru/files link was in the same state, then with a redirect it becomes https://domain.ru/index.php?route=files
link ( https://domain.ru/files/) and at the same time everything worked as before?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Defman21, 2016-05-08
@Defman21

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question