gedeadisurya
gedeadisurya

Reputation: 111

Configure .httaccess to make wordpress accessed by multiple domain without redirect on nginx & apache server

Hai I have a vestacp that running nginx and apache on CENTOS 7, Short story I have install a wordpress with this address sub.domain.com,

Now I have setup ne domain.org that pointed to directory of wordpress instalation sub.domain.com. and I have configure .httpd.conf and nginx.conf so the domain.org can show the project of sub.domain.com

I tried to access domain.org/about it works and display the information like sub.domain.com,

  1. the problem is I need to type manualy /about because in domain.org WP Post and Page url still showing https://sub.domain.com/

  2. how to make sub.domain.com and domain.org still accessible with single WordPress installation, let say sub.domain.com is blocked in some country so they need new domain domain.org that accessible from blocked country, so domain.org will showing the same data as sub.domain.com, when sub.domain.com updated so domain.org is also updated

it's possible to replace the at wp_option table to domain.org but I want sub.domain.com still accessible

is there any other method ?

Thanks

Upvotes: 0

Views: 104

Answers (1)

Koala Yeung
Koala Yeung

Reputation: 7893

The Wordpress codex stated that you may directly override the WP_HOME and WP_SITEURL in your wp-config.php file:

define( 'WP_HOME', 'http://example.com' );
define( 'WP_SITEURL', 'http://example.com' );

Naturally, you may build your own domain from $_SERVER variables.

$scheme = $_SERVER['REQUEST_SCHEME'] . '://';
$host = $_SERVER['HTTP_HOST'];
$home_path = '/somepath'; // only needed if your wordpress is in a subfolder.

define( 'WP_HOME', $scheme . $host . $home_path );
define( 'WP_SITEURL', $scheme . $host);

Then the links will be adaptive to the visiting domain.

You might think this is too hackish. Alternatively, you may install Multiple Domain. I haven't try it before, but it claims to achieve the same effect.

Please note that for SEO sake, this is not good. It is more optimal to have all traffics of the same post redirected to the same domain so it's Google's rating is better.

Upvotes: 1

Related Questions