Редирект через .htaccess

Перейдите в каталог сайта и откройте файл .htaccess или создайте его, если он не существует. Добавьте в файл необходимые строки. 

301 redirection from one domain to another

The following lines shall be added to .htaccess (this file is located in the directory of the website, from which you need redirects to happen):

RewriteEngine On
RewriteCond %{HTTP_HOST} old-site.com
RewriteRule (.*)
http://new-site.com/$1 [R=301,L]

where:
old-site.com is the domain to redirect from;
new-site.com is the domain to redirect to.

301 redirection from a domain that has a WWW to a domain that hasn’t

Add the following lines to .htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.site.com$ [NC]
RewriteRule ^(.*)$ 
http://site.com/$1 [R=301,L]

where site.com is your domain name.

301 redirection from a domain that does not have a WWW to a domain that has

Add the following lines to .htaccess:

RewriteEngine On RewriteCond %{HTTP_HOST} ^site.com
RewriteRule (.*) http://www.site.com/$1 [R=301,L]

where site.com is your domain name.

301 redirection for a website with a dedicated IP address

Add the following lines to .htaccess:

RewriteEngine On RewriteCond %{REMOTE_ADDR} 123.123.123.123
RewriteRule ^(.*)$ http://site.com [R=301,L]


where site.com is your domain name.

301 redirection from https:// to http://

Add the following lines to .htaccess:

RewriteEngine On RewriteCond %{SERVER_PORT} ^443$ [OR]
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$
http://site.com/$1 [R=301,L]

where site.com is your domain name.

301 redirection from http:// to https://

Reference shall be made to: Redirection from http to https.

Если вы не нашли ответ, спросите у нас!
Запросить поддержку