Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Hardware>>Can I forward a page by the URL used to get to it?

Can I forward a page by the URL used to get to it?

I have a domain, I'll call it "url.com".
I have a subdomain, I'll call it "subdomain.url.com".

Currently if "http://url.com" is visited or "http://subdomain.url.com" is visited they go to the exact same "index.html" page/website.

I want to have that "index.html" page recognize what URL was typed in to get to it so that if "http://subdomain.url.com" it will forward them to "http://url.com/directory/".

If "http://url.com" is typed in, I want the page to stay where it is.

How can I do this? My host does not allow subdomain forwarding.
Thank you!

Have a look at felgall's comments in

http://www.codingforums.com/showthread.php?t=107507

It's really quite easy. Just put this in the <HEAD> of your page:


<script type="text/javascript">
// <![CDATA[
var host = location.host;
if(host == "subdomain.url.com") location.href = "http://url.com/directory";
// ]]>
</script>


 

TOP

Hyperthreading hurts s
HP sharpens blade PC l
Apple goes for Quad po
Itanium gets scaled do

For more info

HP sharpens blade PC l
Hyperthreading hurts s
can not call click() i
script does not work o
smart menu 
write to an html file 
FireFox doesn't recogn
Changing e.keyCode (e.
Clearing a range creat
UPDATE: My mouse over 

News Archive

onChange Help 
beforeload? vs onload.
Problem with document.
decreasing my javascri
Problem with \\ and \ 
how to stop scrolling?
Change Label Text Colo
Can I forward a page b
2 javascript functions
Validating a textbox 

Related stories:

onChange Help
beforeload? vs onload.
Problem with document.ignore in javascript
decreasing my javascript
Problem with \\ and \
how to stop scrolling?
Change Label Text Color and Its Shade of Disabled Buttons
2 javascript functions clashing...
Validating a textbox

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics