F
F
froosty2014-06-12 16:39:26
htaccess
froosty, 2014-06-12 16:39:26

How to redirect using htaccess from one domain to another?

Hello. There was such a problem. 2 domains refer to one site on the server. Those. the sources are the same, and you can get to the site, for example, at the addresses firstdomain.com and seconddomain.com. You need to make sure that if a person comes to the site at http://firstdomain.com, he will be redirected to seconddomain.com with a 301 code. How can this be done with .htaccess? Thanks in advance for your reply.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
froosty, 2014-06-12
@froosty

The answer is found. Maybe someone will help. You need to write the following in htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^firstdomain\.com
RewriteRule ^(.*)$ seconddomain.com/$1 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question