R
R
Randominho2016-04-05 17:07:38
htaccess
Randominho, 2016-04-05 17:07:38

How to write a 301 redirect to https in htaccess?

Now I have a redirect from www to without www:

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


How to redirect to https? So that from www.site.ru redirect to https://site.ru .

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sasha, 2016-04-05
@madmages

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

V
Viktor Taran, 2016-04-05
@shambler81

And google not?

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question