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.

Wildcard Rewrites

Discussion in 'General Discussion' started by creaturecorp, Jul 9, 2005.

  1. creaturecorp

    creaturecorp Registered

    Joined:
    Jul 9, 2005
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    I'm sure that many users here have heard of this issue before. I've enabled wildcard dns by inserting a *.mydomain value into my domain zone with whm.

    This worked very well, but now going to *.mydomain.com brings up the "There is no website configured at this address." message.

    Now, I'm searching for a way of mapping

    *.mydomain.com
    to
    mydomain.com/user.php?user=*

    Can this be done with .htaccess or will httpd.conf files have to be edited? I've tried with .htaccess to no avail.

    ~Creaturecorp
     
  2. rlueth

    rlueth Member

    Joined:
    Feb 20, 2004
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Donald, Oregon
    You need to edit httpd.conf and add the wildcard to the ServerAlias entry for the specified
    VirtualHost. it would look something like this.
    <VirtualHost 192.168.0.1>
    ServerAlias www.mydomain.com mydomain.com *.mydomain.com
    Other Stuff here
    </VirtualHost>
    As well as the dns zone.
    So, In the dns zone add a * cname mydomain.com..
    Hope this helps.
     
    #2 rlueth, Jul 9, 2005
    Last edited: Jul 10, 2005
  3. creaturecorp

    creaturecorp Registered

    Joined:
    Jul 9, 2005
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    That is done, but now i need a method of rewriting the subdomain to the page. Should this be done inside the httpd.conf or in a .htaccess?

    I've got some code here but it hasn't been affecting *.mydomain.com at all.

    RewriteCond %{HTTP_HOST} !^www\.mydomain\.com
    RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.mydomain\.com [NC]
    RewriteRule ^(.*)$ http://www.mydomain.com/user.php?user=$1 [R=301,L]

    This code used in the public_html or root directory still only brings up the 'no website configured...' page.
     
  4. rlueth

    rlueth Member

    Joined:
    Feb 20, 2004
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Donald, Oregon
    edit

    Hello creaturecorp,
    Can you elaborate what you want http://www.mydomain.com/user.php?user=$1 to do?
    Just redirect to a sub.mydomain.com like user.php?user=$1 would be say john, so it gets redirected to john.mydomain.com.?
    If so are the users getting Directories with their name..
    Regards..
     
    #4 rlueth, Jul 13, 2005
    Last edited: Jul 13, 2005
Loading...

Share This Page