Results 1 to 9 of 9
I'm working on a website for a Linux User Group I'm starting. I have created a subdomain on my site for it, and I have a directory with a little ...
- 04-08-2008 #1
[SOLVED] Website Subdomain Redirect
I'm working on a website for a Linux User Group I'm starting. I have created a subdomain on my site for it, and I have a directory with a little test page in it.
My site is:
http://www.techiemoe.com
My subdomain is:
http://klug.techiemoe.com
I'm trying to make it so that if someone navigates to "klug.techiemoe.com" they get redirected to this address, which points to the test page:
http://www.techiemoe.com/klug/
I've attempted this several ways. My host (Brinkster) apparently does not allow you to redirect using the .htaccess file. I've tried modifying this file to say this:
I've tried several permutations of this I've found scattered around the internet. None of them seem to work. Several suggestions said that my host may not allow PHP to be run from the .htaccess file.Code:RewriteEngine on RewriteCond %{HTTP_HOST} ^klug.techiemoe.com RewriteCond %{REQUEST_URI} !^/klug/ RewriteRule (.*) /klug/$1 [L]
Next I looked in the support section of my host, which suggested I use ASP, PHP, or JavaScript. For obvious reasons, I wanted to try the JavaScript. I've added this to the < head > section of my index.htm file:
This results in some strange behavior. When the user types "klug.techiemoe.com" it still loads the main page. However when you click on the title "Techiemoe.com" it tries to redirect to this URL:Code:<script language="javascript"> var whois=location+" " if (whois.indexOf("techiemoe.com") != -1) { window.location ="index.htm" } if (whois.indexOf("www.techiemoe.com") != -1) { window.location ="index.htm" } if (whois.indexOf("klug.techiemoe.com") != -1) { window.location ="klug/" } </script>
I managed to throw in another .htaccess file to redirect the inevitable 404 to the main page for the LUG, but I'd really like to get this working properly. Any suggestions?Code:http://www.techiemoe.com/klug/1
Registered Linux user #270181
TechieMoe's Tech Rants
- 04-10-2008 #2
Bump.......
Registered Linux user #270181
TechieMoe's Tech Rants
- 04-11-2008 #3
Moved and bumped...
Registered Linux user #270181
TechieMoe's Tech Rants
- 04-11-2008 #4
so if you type the address' in do they go to their own website or does that not even work? do they both go to the same place.
here is a refresh that I use
this is the index.html page and when it loads up it redirects to the destination specified. the content="5 dictates the refresh time, set to lower for quicker redirection.Code:<html> <head> <meta HTTP-EQUIV="REFRESH" content="5; url=http://destination_url.com"> </head> <body> </body> </html>
- 04-11-2008 #5
Yes, regardless of whether I type in klug.techiemoe.com or TechieMoe.com they both end up on my main index page.
Today, for whatever reason, if you type in the subdomain it gives you an error 500. I'm looking into it.
I see what you're talking about but I don't see how it applies to this situation. I'm not trying to redirect all traffic from my site to the other index page, only traffic that comes in under the subdomain... could you explain this one to me a bit more?here is a refresh that I use
this is the index.html page and when it loads up it redirects to the destination specified. the content="5 dictates the refresh time, set to lower for quicker redirection.Code:<html> <head> <meta HTTP-EQUIV="REFRESH" content="5; url=http://destination_url.com"> </head> <body> </body> </html>
Registered Linux user #270181
TechieMoe's Tech Rants
- 04-11-2008 #6
my post would work if your subdomains were served from different directories. when you set these up are you settings up virtual hosts or are you using a web admin like cpanel to do it? do you have access to your apache configuration?
- 04-11-2008 #7
The way I have it set up now is everything is inside my main web directory, /public_html/, and everything directs to the index.htm file in there. The other index.htm for KLUG is in the subdirectory /public_html/klug/.
I did not set up the subdomain myself. Someone at my hosting company did it. I do not think I have access to my server configuration.when you set these up are you settings up virtual hosts or are you using a web admin like cpanel to do it? do you have access to your apache configuration?Registered Linux user #270181
TechieMoe's Tech Rants
- 04-11-2008 #8
how about something like this
I found that here How to redirect user based on domain requested? [Archive] - PHPBuilder.comCode:<?PHP switch ($HTTP_HOST) { case "www.firstdomain.com": header("Location: /firstdirectory/index.php"); break; case "www.seconddomain.com": header("Location: /seconddirectory/index.php"); break; case "www.thirddomain.com": header("Location: /thirddirectory/index.php"); break; default: header("Location: site_index_page.html"); ) ?>
- 04-11-2008 #9
Aha! Not that exact thing, but the same idea in JavaScript, seems to have done the trick. Thanks for steering me in the right direction.
Registered Linux user #270181
TechieMoe's Tech Rants




