473,385 Members | 1,267 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem rying to Redirct Domain

I have a web site to which multiple domains point and I want to redirect to
a specific subdirectory for specific domain references. I found the
following script and am trying to use it but I cannot get it to work. I
added the alert statements to try to see what is happening but they both
retund a value of 0? Any ideas as to how I can accomplish this?

Wayne

==============================
<script language="JavaScript">
<!--
alert("Location.Hostname: " & location.hostname);
alert("urlloc: " & location.href);
if ( location.hostname == "AltDomain.org" ) {
window.location = "/AltDomainsubDirectory/";
} else if ( location.hostname == "domain_two.com" ) {
window.location = "/users/domain_two/";
} else {
// build current content
}
-->
</script>
Sep 4 '05 #1
6 3050
Wayne Wengert schrieb:
I have a web site to which multiple domains point and I want to redirect to
a specific subdirectory for specific domain references. I found the
following script and am trying to use it but I cannot get it to work. I
added the alert statements to try to see what is happening but they both
retund a value of 0? Any ideas as to how I can accomplish this?

Wayne

==============================
<script language="JavaScript">
<!--
alert("Location.Hostname: " & location.hostname);
alert("urlloc: " & location.href);
if ( location.hostname == "AltDomain.org" ) {
window.location = "/AltDomainsubDirectory/";
} else if ( location.hostname == "domain_two.com" ) {
window.location = "/users/domain_two/";
} else {
// build current content
}
-->
</script>


First of all: location is an object, you have to set the path to the property href:

window.location.href = "/AltDomainsubDirectory/";

You should get the actual hostname bei window.location.hostname
Sep 4 '05 #2
Wayne Wengert wrote:
I have a web site to which multiple domains point and I want to redirect to
a specific subdirectory for specific domain references. I found the
following script and am trying to use it but I cannot get it to work. I
added the alert statements to try to see what is happening but they both
retund a value of 0? Any ideas as to how I can accomplish this?

Wayne

==============================
<script language="JavaScript">
<!--
alert("Location.Hostname: " & location.hostname);

alert("Location.Hostname: " + location.hostname);
alert("Location.Hostname: " , location.hostname);
Google "javascript concatenation"

Mick
alert("urlloc: " & location.href);
if ( location.hostname == "AltDomain.org" ) {
window.location = "/AltDomainsubDirectory/";
} else if ( location.hostname == "domain_two.com" ) {
window.location = "/users/domain_two/";
} else {
// build current content
}
-->
</script>

Sep 4 '05 #3
Martin;

Thanks for the response. I think I am setting the target directory as you
indicated? After correcting my alert statements it turns out that the domain
retuned by location.hostname and location.href are both the same value - the
url of the site, not the url that the user typed in?

Also, if I change "location.hostname" to "window.location.hostname" it does
not seem to change anything?

Wayne

"Martin Kurz" <in**@martinkurz.in-berlin.de> wrote in message
news:11***************@elch.in-berlin.de...
Wayne Wengert schrieb:
I have a web site to which multiple domains point and I want to redirect
to
a specific subdirectory for specific domain references. I found the
following script and am trying to use it but I cannot get it to work. I
added the alert statements to try to see what is happening but they both
retund a value of 0? Any ideas as to how I can accomplish this?

Wayne

==============================
<script language="JavaScript">
<!--
alert("Location.Hostname: " & location.hostname);
alert("urlloc: " & location.href);
if ( location.hostname == "AltDomain.org" ) {
window.location = "/AltDomainsubDirectory/";
} else if ( location.hostname == "domain_two.com" ) {
window.location = "/users/domain_two/";
} else {
// build current content
}
-->
</script>


First of all: location is an object, you have to set the path to the
property href:

window.location.href = "/AltDomainsubDirectory/";

You should get the actual hostname bei window.location.hostname

Sep 5 '05 #4

"Mick White" <mw***********@rochester.rr.com> wrote in message
news:qh*******************@twister.nyroc.rr.com...
Wayne Wengert wrote:
I have a web site to which multiple domains point and I want to redirect
to a specific subdirectory for specific domain references. I found the
following script and am trying to use it but I cannot get it to work. I
added the alert statements to try to see what is happening but they both
retund a value of 0? Any ideas as to how I can accomplish this?

Wayne

==============================
<script language="JavaScript">
<!--
alert("Location.Hostname: " & location.hostname);

alert("Location.Hostname: " + location.hostname);
alert("Location.Hostname: " , location.hostname);
Google "javascript concatenation"

Mick
alert("urlloc: " & location.href);
if ( location.hostname == "AltDomain.org" ) {
window.location = "/AltDomainsubDirectory/";
} else if ( location.hostname == "domain_two.com" ) {
window.location = "/users/domain_two/";
} else {
// build current content
}
-->
</script>

Sep 5 '05 #5
Thanks Mick. I always forget those difference between languages. Changing
the "&" to "+" got the alert statements working but I still am not getting
the url the user is entering?

Wayne

"Mick White" <mw***********@rochester.rr.com> wrote in message
news:qh*******************@twister.nyroc.rr.com...
Wayne Wengert wrote:
I have a web site to which multiple domains point and I want to redirect
to a specific subdirectory for specific domain references. I found the
following script and am trying to use it but I cannot get it to work. I
added the alert statements to try to see what is happening but they both
retund a value of 0? Any ideas as to how I can accomplish this?

Wayne

==============================
<script language="JavaScript">
<!--
alert("Location.Hostname: " & location.hostname);

alert("Location.Hostname: " + location.hostname);
alert("Location.Hostname: " , location.hostname);
Google "javascript concatenation"

Mick
alert("urlloc: " & location.href);
if ( location.hostname == "AltDomain.org" ) {
window.location = "/AltDomainsubDirectory/";
} else if ( location.hostname == "domain_two.com" ) {
window.location = "/users/domain_two/";
} else {
// build current content
}
-->
</script>

Sep 5 '05 #6
Wayne Wengert wrote:
Thanks Mick. I always forget those difference between languages. Changing
the "&" to "+" got the alert statements working but I still am not getting
the url the user is entering?


Please don't top-post.

What do you mean by 'the URL the user is entering'?

The Location object is accessed through the window object. To see the href:

alert( window.location.href );

or more simply

alert( location.href );

Note the lower case 'l' for 'location'.

<URL:http://docs.sun.com/source/816-6408-10/location.htm#1193494>

The href of the current window is normally displayed in the browser's
address field but you have no access to that using script (unless you
know of a browser that specifically gives you access to it).

The href of the window is whatever it is, the user can type whatever
they want into the address field, it will not modify the Location object
until the user asks the browser to load the new URL. When that happens,
your script is unloaded and you can't access the new Location.

[...]

--
Rob
Sep 6 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tony Archer | last post by:
(Forgive the dupicate post, I had left out the OS Version out of the prior post.) Gentlemen, your urgent help is needed in solving a STRANGE problem. I have two servers a dev box, and a...
1
by: Rahul Chatterjee | last post by:
Hello all I have a web page which has 3 frames. The top and the left navigation frames are on a separate domain. The right display frame initially starts on the same domain as the other two...
2
by: Vaap | last post by:
I did lot of googling to see if I can solve the SQL server not found problem while trying to run ASP.Net community starter kit from an XP machine to Windows 2003 server hosting SQL server 2000...
5
by: Dany C. | last post by:
We have install a valid SSL certificate issued to www.mycompany.com on our web server running IIS 6.0 / win2003 SP1. Then we have created a sub domain pointing to the same server for our web...
3
by: musosdev | last post by:
Hi guys I've got the following error on a project which is running locally on a vs2005 machine (built in webserver), trying to connect to my win2k3 server active directory. the error is... ...
0
by: sudosue | last post by:
I have a systems analyst who came to me with a problem with retrieving a PDF file from a clients website. I've reduced the explaination to the bare facts thus if you need more information just let...
1
by: eblackmo | last post by:
I have a test network consisting of four servers running windows 2003 server R2 SP2. I have set up a domain which functioned correctly for about a day and a half until the other servers decided they...
1
by: raviviswanathan.81 | last post by:
Hello, So we have a webmaster who sets document.domain to some domain. After that, we try to create and inject text inside an iframe by getting the iframeID.contentDocument (or...
2
by: Mlebanon | last post by:
Dear I want to redirct our website to another URL. the website as an example is http://www.XXX.com.qa and I want to redirct it to http://www.XXX.com/?posl=QA&uci=5277&rci=5277. i tried to...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.