Using Multiple Subdomains on a Single WordPress Installation

Tiempo de lectura: < 1 minuto

We will learn today how we can redirect different subdomains using just one WordPress.

Room - pexels

First, we need to create our subdomain DNS and it must point to the same IP where WordPress is stored (i.e. the original domain that we want to duplicate).

We are now creating the SSL certificate and indicating that our WordPress service should open at the root, we need to do this on the hosting server.

We now need to edit the wp-config.php file so it opens the site with different configuration depending on the domain:

if ($_SERVER['HTTP_HOST'] == 'sub.dominio.com') { define('WP_HOME', 'https://sub.dominio.com'); define('WP_SITEURL', 'https://sub.dominio.com'); } else { define('WP_HOME', 'https://dominio.com'); define('WP_SITEURL', 'https://dominio.com'); } 

We will now open sub.dominio.com and verify that it opens correctly and loads all resources.

Leave a Comment