Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Using rewrite to get subdomains of addon domains

Discussion in 'General Discussion' started by houchin, Jul 10, 2003.

  1. houchin

    houchin Member

    May 16, 2003
    Likes Received:
    Trophy Points:
    Hi all,

    I've seen all of the posts on how CPanel (even up to v7) doesn't let you create subdomains of addon domains. But then I thought, why can't we just use mod_rewrite to do the right thing. My host manually added my subdomain into the DNS, so now I can access both and, but unfortunately the both point to

    So I've been trying to use the rewrite engine to fix that. I created a directory "sub" in the addon directory, and tried creating a .htaccess file that does the rewrite. Here's my attempt, which isn't working:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^$ [NC]
    RewriteRule ^(.*)  /sub/$1
    (I'm starting simple just to get the most basic stuff working)

    The rule does indeed run, but it recurses until it hits some apache defined limit, so instead of redirecting to "/sub/", it redirects to "/sub/sub/sub/.../sub/sub/"

    Does anyone have any suggestions on how to get this working.

    (other than bugging the CPanel authors to get proper subdomains for addon domains working...) Support Ticket Number: Support Ticket Number:
  2. EcpHosting

    EcpHosting Well-Known Member

    Dec 16, 2002
    Likes Received:
    Trophy Points:
    The bug with the subdomain on the addon is really quite simple (perhaps the folks at Cpanel hasn't figured it out yet) and consists of TWO bugs...

    It all lies within the Apache Conf file. Of course, there are two entries in the conf file (one for the addon and one for the subdomain).

    The First Bug: Server Alias
    The first bug lies within the Server Alias file. Normally a Server Alias for a domain is " so that any time someone types in the domain [with or without the WWW] it will route to that account. instead the addon server alias is: *

    Being that the addon domain is higher than any subdomain placed under it on the conf file, it take precedence. That little asterisk (*) is what kills the possibility of any addon domain from working. If you were to change that asterisk from a * to a 'www', this will open up the gateway for room for the addon to work.

    The Second Bug: Document Root
    The is on the subdomain conf entry itself. There really isn't a bug, if this wasn't an subdomain for an addon. The document root is showing the root as being in a folder that doesn't exist (thinking the subdomain folder is under the public_html folder). This, of course, isn't the case, as the subdomain folder lies within the addon domain folder.

    A simple fix of both entries above and an addon works just fine! I just hope CPanel would come around to fixing this. Support Ticket Number:
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice