Subdomains redirecting to primary domain

Scenario

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

Primary domain – domain.com
Subdomain – demo.domain.com

Issue: demo.domain.com redirects to domain.com/demo or domin.com

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} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301,NC]

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.