Asia Expat

Member
Apr 22, 2008
7
0
51
I have a set of canonical 301 redirects in place in htaccess... i.e. example.com redirects to www.example.com.

However, it's causing problems with subdomains and beta.example.com becomes example.com/beta/

The general consensus with Apache experts is that the htaccess code is not the problem, rather there is something within cPanel clashing with the htaccess code. Are there any cPanel engineers or gurus here that can suggest what might be causing this issue? The code from htaccess is below...

Code:
# Externally redirect requests for non-blank, non-canonical hostnames to canonical hostnames
#
# Canonicalize "newservice"
RewriteCond %{HTTP_HOST} newservice\.example\.com
RewriteCond %{HTTP_HOST} !^newservice\.example\.com$
RewriteRule ^(.*)$ http://newservice.example.com/$1 [R=301,L]
#
# Canonicalize "beta"
RewriteCond %{HTTP_HOST} beta\.example\.com
RewriteCond %{HTTP_HOST} !^beta\.example\.com$
RewriteRule ^(.*)$ http://beta.example.com/$1 [R=301,L]
#
# Canonicalize all others
RewriteCond %{HTTP_HOST} example\.com$ [NC]
RewriteCond %{HTTP_HOST} !^(www|newservice|beta)\.example\.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
 
Last edited:

Asia Expat

Member
Apr 22, 2008
7
0
51
I'd really rather not bother the cPanel team with a support ticket over this issue... is there anyone that might have any ideas what aspect of cPanel may be clashing with the redirects, causing the subdomains do redirect to the subdirectory?
 

Infopro

Well-Known Member
May 20, 2003
17,113
513
613
Pennsylvania
cPanel Access Level
Root Administrator
Twitter
Not sure if this is helpful, but, you know what you want to do, but are using code that appears to not have been generated by cPanel's redirect tool.
Why not remove all of this and re-add it manually using the redirect tool feature. This way you know it will work with cPanel.