Forum Moderators: phranque

Message Too Old, No Replies

real vs wildcard subdomains

httpd conf problems

         

midtempo

9:17 am on Jul 10, 2008 (gmt 0)

10+ Year Member



Hi,

I'm trying to set up wildcard subdomains so that site users can have their own sub-sites at [username.example.com...]

however, I've also got a number of real subdomains set up, e.g. [forum.example.com...] & [shop.example.com...]

using

ServerAlias *.example.com

results in all subdomain requests being directed to the user system.

Is there a way to deal with this without having to completely restructure the (rather large) website?

Thanks

Kris

jdMorgan

2:38 pm on Jul 10, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The simplest approach might be to define separate VirtualHost containers for "forum" and "shop" and place them before the wildcard vHost container -- Apache will take the first vHost that matches, thereby bypassing the wildcard "user" vHost.

Another method would be to create the "forum" and "shop" subdirectories as if they were users, and then use mod_rewrite to point requests for those two "usernames" back to the proper filesystem location for the forum and cart. You could also use symbolic links in those two subdirectories to accomplish the same thing at the operating system level, as opposed to doing it at the server level.

mod_alias and mod_rewrite allow for complete independence of filepaths on URLs -- You can map any URL to any filepath you like.

Which of these methods you choose depends primarily on your 'comfort level' with each approach.

I would recommend that you think long and hard about where your site might go (and grow) in the future, and consider reserving such usernames as "news," "blog," "search," "gallery," "reviews," "specials," "support," "archives," etc. -- You do not want to allow one user to create an account that will dictate how you must structure your site in the future.

Jim

midtempo

3:12 pm on Jul 10, 2008 (gmt 0)

10+ Year Member



thanks jim,

i've already got a list of blocked usernames (which also incl. webmail, secure, etc.)

i'd thought about the separate VirtuaHost containers, however the server that it's set-up on is a "dedicated virtual", where all changes are made to vhost.conf files - separate ones for the main site and the 'real' subdomains, and kept in different parts of the file structure.

the httpd.conf is read only and governed by plesk - changes to it are not recommended.

looks like i'm going to have to go down the mod_rewrite route...