Forum Moderators: phranque
[subdomain.example.com...] would be redicrected to [example.com...]
and [subdomain.example.com...] would be redirected to [example.com...]
Any advice how I could go about this? I'm assuming mod_rewrite is the proper method to use.
Any help much appreciated.
- Adam
Welcome to WebmasterWorld!
Check out the mod_rewrite and regular expressions references cited in our charter [webmasterworld.com] to get started.
You will need to use
RewriteCond %{HTTP_HOST} ^(.+)\.example\.com
to find and create a back-reference to the subdomain name for use in the RewriteRule.
Jim
It's not clear what you're trying to accomplish with this project.
Jim
When going to a subdomain (http://subdomain.example.com), I would like it to rewrite the URL on the server level (not redirect) to a file in the root directory, not any sub directory under the root folder, as most subdomains work.
For example, [subdomain.example.com...] would display [example.com...]
This would be one static rewrite (this one subdomain by itself with no file specified) would direct to one specified file, never changing.
In addition to this, I would like to have a rewrite for any file specified with the subdomain to point to a file of the same name in the root folder.
For example, [subdomain.example.com...] would direct to [example.com...]
So whatever you specify as the file with the subdomain would go to the file in the root directory with that same name. So it basically, in this case, dropped the subdomain.
I know, it's a weird setup, and I hope I've explained it so you can understand.
- Adam
So, the question here is, what mechanism is causing your subdomain to *not* resolve to your Web root folder?
If you're stuck with some "control panel" or if your host has put code into httpd.conf to 'map' your subdomain to a subfolder, then using a rewrite may not be possible, and you'll have to redirect to the main domain from the subfolder. With 'control panel' subdomains, security considerations often prevent rewriting 'up' from a subdomain's subdirectory into the main domain's directory.
Actually, a possible way out if that is the case is to rewrite some or all of the URLs for the main domain into the subdomain's subdirectory, and move some or all of the main domain's files into that subdir. Sometimes you have to grab either end of the rope that you can...
Sorry for all the back-and-forth, but the specifications have to be nailed down before any code can be generated.
By what mechanism are requests for the subdomain URLs now being mapped into a subdirectory?
Jim