1

I have a wordpress site that i want to run 2 hosts with 2 different domains.

Site in the first host with the domain example1.com works correctly but in the second host domain example2.com redirect to example1.com domain.

There is no set redirect in the .htaccess file.

DNS of each of the 2 domains are set up correctly.

My question is how should I get it which part of the program code is this redirects ?

1
  • 1
    Options home and site_url are correct? Try adding to the wp-config.php file of example2.com wordpress: define('WP_HOME','http://example2.com'); define('WP_SITEURL','http://example2.com');
    – nmr
    Aug 30 '18 at 22:17
0

Edit functions.php

To be certain your WordPress site is pointing to the correct URL do this.

  1. Got to your themes functions.php file found at /wp-content/themes/ theme-name
  2. Add these two lines to the file, immediately after the initial <?php line.

update_option( 'siteurl', 'http://example.com' );

update_option( 'home', 'http://example.com' );

  1. Make sure you clear all cache and if using CloudFlare, put it into development mode.
  2. Check you have no redirects in your .htaccess files

  3. Now check to see if your site points to the correct URL.

If it doesn't it's likely you have a DNS setting that needs changing. Check your parked domains to make sure one isn't set as a redirect there as seen in the WHM setting I have on my server in the below image.

enter image description here

*Once you have solved the issue, it's a good idea to remove your added code from functions.php. If you don't you won't be able to change these settings in the WordPress setting until you do so.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.