I'm very new to Apache, so please forgive me if the jargon isn't right.
I have a Debian based Apache 2 server, and I want to create pseudo subdomains. As I understand it, this is achieved through an entry in one of the Apache conf files.
For example, lets say we have the domain 'domain.tld'. I want to create 'sub.domain.tld'. The 'real' way to do it takes time to become active, and seems overly complex (even though the control panel I'm using creates it all for me), AND isn't accessible as http://www.sub.domain.tld, only as http://sub.domain.tld.
I read a reference somewhere on the web that talked about 'pseudo' subdomains, which are just Apache redirects to the content of directories within domain root directory (the html folder). Unfortunately, it didn't detail how to do that.
What I'm looking for is a single entry in an Apache .conf file that reads the request 'sub.domain.tld' and simply redirects to domain.tld/sub (while leaving the displayed address as 'sub.domain.tld'). If /sub doesn't exists, an error is generated. As soon as /sub is created, the redirect comes into effect and sub.domain.tld works.
Is this possible?
If so, how do I get it done?
Thanks
CTB
Oh Lord, please help me be the person my dog thinks I am.
You might want to consider adding directives for all the server error pages in the www.sub domain to redirect to that index, so no matter what it'll get there.
Probably not the best solution, but maybe it'll hold you over.
My Site
Web Design On Linux: Sure It Takes Longer To Get It Right In IE, But Who Really Cares?
Thanks Pirate (or should that just be' aaarrrrgg'),
I've been doing some diggin on this, and was amazed at how simple the solution actually is.
Assuming the A record in the zone configuration is set up to take wildcards, all I needed to do is add this to vhosts.conf...
ServerAlias domain.tld *.domain.tld
And now any.domain.tld ends up at domain.tld, where that "php love" can weave its magic. And because Apache simply starts at the top and works its way down until it finds a match, if there are real sub.domains, as long as their <VirtualHost> records come before this one, Apache will handle them.
I love the simplicity of it.
Thansk for your help.
Cheers CTB
Oh Lord, please help me be the person my dog thinks I am.
Bookmarks