Subdomain in my Wordpress site redirects to the main site

Avatar
  • Answered
I installed Wordpress multisite and added several sites as subdomains. I already configured the wildcard subdomain in cPanel. But now when I try to access the site on the subdomain I get redirected to the main site. This also happens when I try to access webmail.mydomain.com, I get redirected to mydomian.com instead. So how to fix this issue?
Avatar
Arn
Hello, Sorry for the problem with your webmail getting re-directed to the main domain. This issue has to do with the re-direct being used by WordPress. To fix this you would need to URL rewrite that redirects to the proper URL. To do this, you edit the .htaccess file found in the root of your WordPress multisite installation file and add an exception for that URL that would look something like this:
RewriteCond %{HTTP_HOST} ^webmail.example.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com/webmail [NC]
RewriteRule ^(.*)$ http://example.com:2095 [L,R=301,NC]
Of course the domain "example.com" would be replaced with your domain name. You could also tell people to directly type in example.com:2095. The "2095" is the port for accessing webmail on the web server. The rule needs to go at the BEGINNING of your re-write rules. Safest place would be directly under the "RewriteEngine on" statement. I hope this helps to answer your question, please let us know if you require any further assistance. Regards, Arnel C.