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!

Unlimited subdomains based on mod_rewrite script

Discussion in 'General Discussion' started by Emerican0525, Sep 2, 2012.

  1. Emerican0525

    Emerican0525 Registered

    Sep 2, 2012
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Root Administrator

    I am developing an application for a client who would like each registered user to have their own subdomain which points to the application. For example, say the clients name is bob then he should access the application via

    To achieve this I am trying to use mod_rewrite with the following script:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ([^\.]+)\.domain\.com
    RewriteRule ^(.*) /index.php?id=%1 [L]

    I am adding the script using the apache configuration functionality in WHM and I am pasting the script in the "after all virtual hosts" part of the httpd configuration.

    When I try access a subdomain for example, I keep getting the cPanel "Default Web Site Page" instead of the index page.

    Any help will be greatly appreciated.
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Apr 11, 2011
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Root Administrator
    Hello :)

    You can try modifying the application so that the subdomain is created automatically after a user is registered. This type of setup requires the use of our cPanel APIs, as documented here:


    Thank you.
    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