Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Server Operation

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Thread Tools Display Modes
Old 23rd November 2009, 21:49
sfunk1x sfunk1x is offline
Join Date: Jun 2009
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default Apache defaulting to last created virtualhost conf file in folder

Hey all -

I've got a CentOS 5.2 server running Apache 2 and a menagerie of other packages. I'll try to make this quick:

- Server running Apache configured to load a variety of virtualhost configuration file in a /etc/httpd/conf/vhost folder. It loads all the virtual host files just fine and all the websites appear (subdomains and otherwise).

Main issue:

If a user browses something like 'nodomainexists.domainname.com' into a browser url bar, you're taken to the site whose vhost file was created last. I would much rather have users who attempt to use invalid subdomains to be forwarded to a specific virtualhost file (that runs the main website/frontend). How would I go about making sure that all non-existant subdomains get routed to a specific virtualhost?

For example:

last.domain.com exists (vhost file was created last)
not.domain.com doesn't exist (no vhost file, etc)
www.domain.com does exist (has vhost file, valid site)

When a user goes to not.domain.com, they'll get last.domain.com instead of being sent to www.domain.com.

How would I go about making the www.domain.com a catch all for bad and/or misspelled subdomains?

Thanks in advance!

Last edited by sfunk1x; 24th November 2009 at 01:20.
Reply With Quote
Sponsored Links
Old 24th November 2009, 15:59
falko falko is offline
Super Moderator
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,749 Times in 2,579 Posts

Make sure that the ServerName/ServerAlias directives in your vhosts just list the domains/hostnames that the vhosts should listen to, and then create a default vhost in your Apache configuration before all other vhosts.
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Postfix delivery problem erebus Installation/Configuration 8 29th July 2014 21:17
Update error - Apache no longer works bswinnerton Installation/Configuration 4 16th November 2009 23:25
Why do I get some errors during the reinstallation ? arastirici General 7 15th April 2009 17:50
debian etch courier pop3 issue docean Installation/Configuration 6 20th March 2008 16:38
Howto suggestion suse PhP ver 4 + Ver 5 wwparrish Suggest HOWTO 11 7th August 2006 14:29

All times are GMT +2. The time now is 22:03.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.