Subdomains redirecting to primary domain


WordPress is installed for the primary domain. WordPress is installed for a subdomain. Subdomains set up under the primary domain.

Primary domain –
Subdomain –

Issue: redirects to or

Check if there is an .htaccess file in the subdomain directory:

If not, create an .htaccess file and include the following:

# nano /home/domain/public_html/demo/.htaccess
# BEGIN WordPress
RewriteEngine On
RewriteBase /demo/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /demo/index.php [L]
# END WordPress

If needed…Force www. version of domain to be used

RewriteEngine on
RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [L,R=301,NC]