CityHost.UA
Help and support

How to redirect to another domain?

If it is necessary to set up a redirect to another domain with URI preservation, you just need to add the following rule to the .htaccess file located [in the root directory of the site] :

 

RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^DOMAIN_NAME_1.ZONE$ [NC] RewriteRule ^(.*) http://DOMAIN_NAME_2.ZONE/$1 [L,R=301]

 

If it is necessary to configure a redirect to another domain without saving the URI to the main page, you just need to add the following rule to the .htaccess file located [in the root directory of the site] :

 

RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^DOMAIN_NAME_1.ZONE$ [NC] RewriteRule ^(.*) http://DOMAIN_NAME_2.ZONE/ [L,R=301]

 

From HTTP to HTTPS:

 

RewriteEngine On RewriteBase / RewriteCond %{HTTP:SSL} !=1 [NC] RewriteRule ^(.*) https://domain.com/$1 [L,R=301]

 

[Example] implementation of the need to create a redirect from all pages of the site citydomain.com.ua and the alias - www.citydomain.com.ua to the site cityhost.ua:

RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^citydomain.com.ua$ [NC] RewriteRule ^(.*) https://cityhost.ua/$1 [L,R=301] RewriteCond %{HTTP_HOST} ^www.citydomain.com.ua$ [NC] RewriteRule ^(.*) https://cityhost.ua/$1 [L,R=301]

For quick access to the .htaccess file and its editing, you can use [file manager]

 

From www to a domain without www

 

 

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

 

From a domain without www to a domain with www

 

 

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