Multiple domains on one WP installation

This may not be the greatest SEO idea but it may be useful in some cases. Anyway I thought I’d share this little trick as it proved very handy for one of my recent clients.

Basically WordPress allows you to manipulate your configuration file so that when certain criterions are met you can override the default home and blog URI’s set in the database.

By doing so you can have more or less unlimited domains pulling the same files and data from one single WordPress installation.

Here’s how you do it

Open wp-config.php in your favourite editor (Notepad, Dreamweaver etc.) and add the following:

if (preg_match("/\bwww.example1.com\b/i", $_SERVER['REQUEST_URI']) || preg_match("/\bwww.example1.com\b/i", $_SERVER['HTTP_HOST'])) {
define('WP_SITEURL', 'http://www.example1.com');
define('WP_HOME', 'http://www.example1.com');
}

If you need more domains just add more by repeating the above starting the next “block” with elseif.

Feel free to comment and/or suggest different ways of doing this.

About Author

4 Comments on “Multiple domains on one WP installation”

  1. Здравствуйте! Так приятно оказаться на стоящем сайте. Всем создателям респект и уважуха за ваши труды!

Comments are closed.