Forum Moderators: phranque

Message Too Old, No Replies

Cpanel Wildcard

         

creaturecorp

4:07 pm on Jul 1, 2005 (gmt 0)

10+ Year Member



I've now got Wildcard dns running by adding

*.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...

creaturecorp

11:05 pm on Jul 1, 2005 (gmt 0)

10+ Year Member



BUMP

Nothing's working...

jdMorgan

2:50 am on Jul 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



creaturecorp,

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

creaturecorp

10:27 pm on Jul 15, 2005 (gmt 0)

10+ Year Member



Thanks for the reply!

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?

Anyango

10:34 pm on Jul 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



creaturecorp,

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

creaturecorp

8:20 pm on Jul 17, 2005 (gmt 0)

10+ Year Member



JDmorgan,

I understand now what I'm missing...

I'm wondering now if you have any suggestions what should be put in the httpd.conf file so that it behaves properly. I hope this request doesn't sound too obtuse.

jdMorgan

4:05 pm on Jul 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See the ServerName and ServerAlias directives in Apache core [httpd.apache.org].

See also Apache virtual hosting documenation [httpd.apache.org]

Jim

creaturecorp

1:08 am on Jul 20, 2005 (gmt 0)

10+ Year Member



Hey 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!

jdMorgan

2:07 am on Jul 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Don't use a canonical URL in the last line, then. Doing so forces a redirect. Try using only

RewriteRule ^(.*) /user.php?user=%1&action=$1 [L]

Jim