The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Unlimited subdomains based on mod_rewrite script

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

  1. Emerican0525

    Emerican0525 Registered

    Joined:
    Sep 2, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hello,

    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 http://bob.domain.com.

    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 test.domain.com, 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

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    654
    Trophy Points:
    113
    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:

    SubDomain
    DomainLookup

    Thank you.
     
Loading...

Share This Page