Forum Moderators: phranque

Message Too Old, No Replies

How to IGNORE subdomains?

         

briandunning

11:35 pm on Jun 15, 2005 (gmt 0)

10+ Year Member



Is there a way to have Apache IGNORE any subdomain, and simply route all requests - regardless of whether there's a subdomain - to the same page at domain.com?

jdMorgan

11:45 pm on Jun 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



briandunning,

Welcome to WebmasterWorld!

Assuming you've already got wild-card DNS set up so that all subdomain requests arive at your server, then all you need is a wild-card default server name defined in httpd.conf. You can also add a couple of lines of mod_rewrite code if you want to redirect those subdomain requests rather than letting them remain in the user's address bar (and possibly cause duplicate-content issues with search engine rankings).

A bit more information about your current situation and goals would be helpful in getting good answers...

Jim

briandunning

12:04 am on Jun 16, 2005 (gmt 0)

10+ Year Member



Yes, I do have a lot of URL rewriting going on in my htaccess file, and that's working fine - but none of it deals with subdomains.

I am not aware of wildcard DNS settings. At the risk of asking a question outside the scope of this Apache forum, can you expand on this?

(I *DO* want any subdomains to remain in the user's address bar.)

jdMorgan

12:46 am on Jun 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What happens right now when you request a subdomain of your domain (other than "www") with your browser?
What do you want to happen?

Jim

briandunning

2:11 am on Jun 16, 2005 (gmt 0)

10+ Year Member



If I request anything.domain.com, my browser replies with "Server not found." I want it to go straight to domain.com, but have anything.domain.com still show in the browser's address bar.

jdMorgan

2:47 am on Jun 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, this is a two-step process. First, you have to set up an "A record" in your DNS "zone file" to define the new subdomains --or a wild-card subdomain-- to point to your server's IP address. So, you'll need to figure out how to access your DNS data, and this varies by service.

Once that is done, you need to modify your server configuration (httpd.conf) to tell the server what to do with requests for those subdomains. Again, you can define specific subdomains or just use a wild-card to catch all possible subdomains.

I'll leave it at high-level for now, and we can address your specific questions as they come up.

Jim