Point any and all subdomains to the same location - Apache

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Point any and all subdomains to the same location - Apache

Post by phice »

I'm looking for a htaccess/conf modification that will forward any and all subdomains to the same location (eg: to the main www location), but keep the same subdomain. Possibly something like *.my.dom => /public_html/ ?

Also, I'd like to be able to forward "my.dom" to "www.my.dom" if there isn't a subdomain present.

Many thanks in advance.
Image Image
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

Unless I'm mistaken, you have to have a DNS entry for each subdomain. In other words, wildcards won't work. You'd have to use each subdomain redirection.
e.g.
redirect sub1.my.dom to http://www.my.dom
redirect sub2.my.dom to ...

There's no need for a www in front, though. The www is the biggest piece of garbage I've ever seen. A waste of four character spaces. ;)
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

That's highly unlikely. You should be able to point any and all subdomains through Apache's httpd.conf.

After rooting around, I was able to modify my windows hosts file to allow a fake domain + subdomain, but it doesnt have a wildcard character that I can find. Furthermore, I found...

Code: Select all

<VirtualHost *.domain.ext:80>
    ServerAdmin webmaster@www.domain.ext
    DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs"
    ServerName www.domain.ext
    ErrorLog logs/www.domain.ext-error_log
    CustomLog logs/www.domain.ext-access_log common
</VirtualHost>
but it doesn't matter if I comment that out or not, it doesn't effect it. So, it shouldn't exactly be through Apache, but possibly through a DNS manager. I'll check into what my server has.
Image Image
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

Fixed problem.
Image Image
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

Hm. It must just be my DNS server, then. Unless I specifically note a subdomain in the records, it can't resolve the address.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

That's probably 'expected' behaviour.

Have you tried: *.example.com. CNAME example.com.
Post Reply