M
M
Maxim Gerasimenko2018-05-26 11:29:15
htaccess
Maxim Gerasimenko, 2018-05-26 11:29:15

How to set up a 301 redirect correctly?

Hello!
There is a website domain 24medcentr.com.
You need to set up a 301 redirect via .htaccess, which would be like this:
24medcentr.com -> https://24medcentr.com
www.24medcentr.com > https://24medcentr.com
https://www.24medcentr.com > https: //24medcentr.com
I wrote the following code:

RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^www.site.ru$ [NC]
RewriteRule ^(.*)$ http://site.ru/$1 [R=301,L]

But when checking the redirect, www.24medcentr.com redirects to two addresses at once:
https://www.24medcentr.com/
https://24medcentr.com/
Tell me how to set up the redirect correctly. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question