473,387 Members | 1,766 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,387 software developers and data experts.

Javascript Q: read subdomainprefix from url

M
Hello,

Could someone please help me out on this problem please :)?

All subdomains are redirected tot our main domain www.lelystad.nl and
with javascript redirected to a specific page, eg (Partial):
if (window.location.href == 'http://touristinfo.lelystad.nl' ||
window.location.href == 'http://touristinfo.lelystad.nl/' ||
window.location.href == 'http://www.touristinfo.lelystad.nl' ||
window.location.href == 'http://www.touristinfo.lelystad.nl/') {

window.location.replace("http://www.lelystad.nl/smartsite.shtml?id=50980");

}
This works like a charm for all the stated subdomains in this script.
But whenever someone choose to typ another subdomain which is not
stated in the script I would like to use the subdomainprefix in an URL
to feed the searchengine:

http://www.lelystad.nl/smartsite.sht...term=SUBDOMAIN

TIA
Grtz,
Marco.

Oct 31 '06 #1
3 1454
do these subdomains exist in reality?

Try http://bannas.google.com/ you wont get very far, because there is
no mapping between the host and the IP for that host.

In short, subdomains have to be real and public for your server to
receive the request. If they are real, using apache rewrites is better
as you say - some people dont have js on.

Oct 31 '06 #2
M@r(o wrote on 31 okt 2006 in comp.lang.javascript:
Could someone please help me out on this problem please :)?

All subdomains are redirected tot our main domain www.lelystad.nl and
with javascript redirected to a specific page, eg (Partial):
if (window.location.href == 'http://touristinfo.lelystad.nl' ||
window.location.href == 'http://touristinfo.lelystad.nl/' ||
window.location.href == 'http://www.touristinfo.lelystad.nl' ||
window.location.href == 'http://www.touristinfo.lelystad.nl/') {

window.location.replace("http://www.lelystad.nl/smartsite.shtml?id=5098
0");

}
This works like a charm for all the stated subdomains in this script.
But whenever someone choose to typ another subdomain which is not
stated in the script I would like to use the subdomainprefix in an URL
to feed the searchengine:

http://www.lelystad.nl/smartsite.sht...m&SThema=0&zoe
kterm=SUBDOMAIN
Dit geeft enige richting, ik heb het niet getest:
(= not tested)

<script type='text/javascript'>

var wloc = window.location.href
var ok = /^http:\/\/www\.lelystad\.nl/i.test(wloc)
var subdom = wloc.replace(/^(www\.)?([^\.]+)\.lelystad.nl*./i,'$2')

if (!ok)
window.location.href =
'http://www.lelystad.nl/smartsite.shtml?id=search&SArea=alm&' +
'SThema=0&zoekterm=' + subdom

</script>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Oct 31 '06 #3

M@r(o wrote:
Hello,

Could someone please help me out on this problem please :)?

All subdomains are redirected tot our main domain www.lelystad.nl and
with javascript redirected to a specific page, eg (Partial):
if (window.location.href == 'http://touristinfo.lelystad.nl' ||
window.location.href == 'http://touristinfo.lelystad.nl/' ||
window.location.href == 'http://www.touristinfo.lelystad.nl' ||
window.location.href == 'http://www.touristinfo.lelystad.nl/') {

window.location.replace("http://www.lelystad.nl/smartsite.shtml?id=50980");

}
This works like a charm for all the stated subdomains in this script.
But whenever someone choose to typ another subdomain which is not
stated in the script I would like to use the subdomainprefix in an URL
to feed the searchengine:

http://www.lelystad.nl/smartsite.sht...term=SUBDOMAIN

TIA
Grtz,
Marco.
I think the JS is not the best choice. Try to use server-side settings.

Val Polyakh
http://trickyscripter.com

Nov 1 '06 #4

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

Similar topics

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: 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
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.