G
G
godpop2015-12-10 13:01:16
PHP
godpop, 2015-12-10 13:01:16

How to link two domains to wordpress?

Hello. Please tell me how can I link two domains to one site on WordPress? I registered everything in dns, it works, it opens the site at two addresses. But the trouble is that the link in the WordPress settings is set to one domain, and it turns out that all absolute links lead to it. How to make them relative so that they don't exist on the second domain?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeniy, 2015-12-10
@godpop

Try writing something like this in config.php:

if($_SERVER['HTTP_HOST']=='domain1.com') {
  define('WP_HOME','http://domain1.com');
  define('WP_SITEURL','http://domain1.com');
}
if($_SERVER['HTTP_HOST']=='domain2.com') {
  define('WP_HOME','http://domain2.com');
  define('WP_SITEURL','http://domain2.com');
}

Add. link:
https://codex.wordpress.org/Changing_The_Site_URL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question