.htaccess

Discussion in 'Apache' started by danpadams, Mar 2, 2005.

  1. #1
    I was curious, does anyone know what codes are used by cPanel when setting up subdomains? I was wanting to do this in much more of an automated way than by going through cpanel and I was thinking it could be done by putting some code in an .htaccess file.

    I probably have several other .htaccess files, so if anyone has any resources they can suggest I would appreciate it also.
     
    danpadams, Mar 2, 2005 IP
  2. Josh

    Josh Peon

    Messages:
    893
    Likes Received:
    82
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I am almost positive you can't do this using .htaccess, cpanel has to go into to DNS file on the server, and add the subdomain there.

    Josh

    edit: Yeah, just found a forum post that proves my point: http://www.webmasterworld.com/forum92/2970.htm .. I dont think there is any (easy) way to modify the hosts file from a client end. You would have to get root access from your server admin, and create a php script that would edit it or something..
     
    Josh, Mar 2, 2005 IP
  3. danpadams

    danpadams Peon

    Messages:
    101
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I was thinking the part of it that makes it so that webalizer picks up the right info on the subdomain. I already have a * in the DNS so that any and all undefined entries get pointed to the correct webspace, which is the one I am using. The webspace then chooses which page to show. Does that clarification help?
     
    danpadams, Mar 2, 2005 IP
  4. Josh

    Josh Peon

    Messages:
    893
    Likes Received:
    82
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ah.. yeah, that might just work. See the code that guy posted in the thread I linked to, using mod_rewrite.


    Josh
     
    Josh, Mar 2, 2005 IP
  5. flawebworks

    flawebworks Tech Services

    Messages:
    991
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    78
    #5
    If wildcard dns is setup: you can configure an htaccess file like so:

    RewriteEngine On
    Options +FollowSymlinks
    RewriteBase /
    Rewrite Rule for jane.domainname.com
    RewriteCond %{HTTP_HOST} jane.domainname.com$
    RewriteCond %{REQUEST_URI} !jane/
    RewriteRule ^(.*)$ jane/$1

    Replace jane with your subdomain folder name; and domainname.com with the domain in question.

    No need for host intervention.
     
    flawebworks, Mar 2, 2005 IP
  6. danpadams

    danpadams Peon

    Messages:
    101
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I have messed with the idea of redirecting a subdomain to a certain folder by the method suggested before, but with the host I am using when I use a subdomain by the method of adding a subdomain via the cPanel interface, it seems to allow webalizer to find the new subdomain, or would that happen anyway if I use the subdomain as part of the URL?
     
    danpadams, Mar 2, 2005 IP
  7. flawebworks

    flawebworks Tech Services

    Messages:
    991
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    78
    #7
    You would have to ask your host specifically on that one; it depends on how their server is setup. I would say no: other hosts (non cpanel) I've worked for while they could do the subdomain thing; log files were not generated. When you install a subdomain from within cpanel; it's all tied in together; and separate log files are generated for the domain, because an entry for the subdomain is written to the http.conf file, at least for a standard cpanel setup.
     
    flawebworks, Mar 2, 2005 IP