View Full Version : .htaccess
danpadams
Mar 2nd 2005, 11:58 am
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.
Josh
Mar 2nd 2005, 12:43 pm
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..
danpadams
Mar 2nd 2005, 12:46 pm
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?
Josh
Mar 2nd 2005, 12:48 pm
Ah.. yeah, that might just work. See the code that guy posted in the thread I linked to, using mod_rewrite.
Josh
flawebworks
Mar 2nd 2005, 1:11 pm
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?
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.
danpadams
Mar 2nd 2005, 1:21 pm
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?
flawebworks
Mar 2nd 2005, 2:10 pm
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.
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.