+2 votes
in Web & Google by (71.8k points)
I want to permanently move my old '.in' domain to new '.com' domain. I am not using cPanel. How can I redirect by making changes in .htaccess file?

1 Answer

+2 votes
by (349k points)
selected by
 
Best answer

Make one of the following changes in the .htaccess file of the old domain. Here example.com is the new domain name. 

1. If new domain uses https and www

RewriteEngine On

RewriteRule ^(.*)$ https:/ /www.example.com/$1 [L,R=301,NC]

2. If new domain uses http and www

RewriteEngine On

RewriteRule ^(.*)$ http:/ /www.example.com/$1 [L,R=301,NC]

3. If new domain is non-www and non-https

RewriteEngine On

RewriteRule ^(.*)$ http:/ /example.com/$1 [L,R=301,NC]

4. If new domain is non-www but uses https

RewriteEngine On

RewriteRule ^(.*)$ https:/ /example.com/$1 [L,R=301,NC]


Use of the [NC] flag causes the RewriteRule to be matched in a case-insensitive manner. That is, it doesn't care whether letters appear as upper-case or lower-case in the matched URI.

The [L] flag causes mod_rewrite to stop processing the rule set. In most contexts, this means that if the rule matches, no further rules will be processed

Use of the [R] flag causes a HTTP redirect to be issued to the browser. If a fully-qualified URL is specified (that is, including http://servername/) then a redirect will be issued to that location. Otherwise, the current protocol, servername, and port number will be used to generate the URL sent with the redirect.

Source: https://httpd.apache.org/docs/2.4/rewrite/flags.html


...