Forum Moderators: phranque
*.mydomain.com. 14400 IN A xx.#*$!.xx.#*$!
to my zone file.
It works wonderfully, and anything.mydomain.com returns a page. However, the page is cPanel's "No website configured at this address". I'm using a bit of .htaccess in conjuction with this as well.
RewriteCond %{HTTP_HOST}!^www\.mydomain\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.mydomain\.com [NC]
RewriteRule ^(.*)$ [mydomain.com...] [R=301,L]
The httpd.conf should be empty at this point and time...
Welcome to WebmasterWorld!
It sounds like you're missing a piece or the puzzle, here.
Your wild-card DNS setting tells the client (e.g. browser) to send the HTTP request via TCP/IP to the IP address that you specified, so all well and good, there.
However, you must also tell the server how to handle the requests for the new subdomains. Essentially, you also need to define the wild-card in httpd.conf and tell it what directory structure(s) to associate with the subdomain request(s). Otherwise, you'll get the default document, as you're seeing.
I believe you can do this with cPanel, but I have't used it in years.
Jim
Well, I've got some code here... let's see if it is appropriate for this.
RewriteCond %{HTTP_HOST}!^www\.mydomain\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.mydomain\.com [NC]
RewriteRule ^(.*)$ [mydomain.com...] [R=301,L]
can this go in the httpd.conf file?
I think Jim mentioned accurately what the problem is but i think you didnt get his point.. your .htaccess code may be well enough but its of no use unless it gets executed by recieving a request. Your cpanel is probably sending the sub-domain requests to the directories you are expecting to recieve that request in. you need to set that up so that it sends all your sub-domain requests to the same root directory as of main directory
See also Apache virtual hosting documenation [httpd.apache.org]
Jim
It appears that I was using the incorrect httpd.conf. I was using /etc/httpd.conf instead of /usr/local/apache/conf/httpd.conf. I wish i could use a different one, so that I don't mess with the main file.
But anway, it actually responds to requests now. I've got this in my .htaccess.
RewriteEngine On
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\. [NC]
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.mydomain\.com(:80)?<>/([^/]*) [NC]
RewriteCond %1<>%3!^(.*)<>\1$ [NC]
RewriteRule ^(.*) [mydomain.com...] [L]
It works nicely, but It redirects to the literal url instead of making in appear seamless... if you know what I mean. I'd rather have it stay at the correct url, which would be [user.mydomain.com...] instead of [mydomain.com...]
Thanks for the wonderful help Jim et all!