473,657 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Redirect to server root address

hi all,

I am trying to re-direct a html page to the root of a server (eg.
localhost:8080/index.html). However the problem is that I dont want to
hard code the name of the server (localhost) as it will change
periodically. I want to reference just the server name (whatever it is)
and then the port no and then the file name. I hope we can achieve this
using Javascript.

So far I have written:
<META HTTP-EQUIV="REFRESH" CONTENT="3;
URL=http://localhost:8080/index.html">

can some genius help me with this.

thanks in advance.

Nov 28 '05 #1
5 8741
sc*****@gmail.c om said the following on 11/28/2005 1:38 AM:
hi all,

I am trying to re-direct a html page to the root of a server (eg.
localhost:8080/index.html). However the problem is that I dont want to
hard code the name of the server (localhost) as it will change
periodically. I want to reference just the server name (whatever it is)
and then the port no and then the file name. I hope we can achieve this
using Javascript.

So far I have written:
<META HTTP-EQUIV="REFRESH" CONTENT="3;
URL=http://localhost:8080/index.html">

can some genius help me with this.

thanks in advance.


var thisURL = document.locati on.href;
var thisDomain = document.domain ;

Now, you have the URL itself, you can pick out the host, add the port,
and your file name.
You also have a reference, where supported, to the domain itself as well.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 28 '05 #2
Thanks for that. But I want to clarify something, will
http://javascript:this .domain:8080/index.html" work.

cheers.

Nov 28 '05 #3
sc*****@gmail.c om said the following on 11/28/2005 1:58 AM:

Please quote what you are replying to.

If you want to post a followup via groups.google.c om, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.
Thanks for that. But I want to clarify something, will
http://javascript:this .domain:8080/index.html" work.


It is easy enough to test but the answer is no.

You will have to build your own URL and then use JS to simply set the
document.locati on.href to the appropriate URL.

document.domain seems to be a property that can be set but not read.
Bummer.

Get the location.href property, then weed out the part you need. It will
be everything from the beginning up to the first '/' that is not part of
the '//'. Then, build your own URL string, set the location.href to that
string, then you are set.

Search the archives. You can probably find something already written
that will give you the current domain.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 28 '05 #4
I found something else within the archives. I need to do exactly this,
but am not sure how to implement it with a javascript method. could
somebody please guide me.

If this is the case, I would use Regular Expressions to return the
first match of:
/[ps]:\/\/([^\/]*\.)$\/?

Not sure on the \/... you might also try:
/[ps]://([^/]*\.)$/?

This should return the following for the following strings:
http://123.123.123.123/here.htm Returns:123.123 .123.123
https://mydomain.com/here.htm Returns:mydomai n.com
http://this.is.my.domain.name Returns: this.is.my.doma in.name

thanks heaps.

Nov 28 '05 #5
sc*****@gmail.c om wrote:
I found something else within the archives. I need to do exactly this,
but am not sure how to implement it with a javascript method. could
somebody please guide me.

If this is the case, I would use Regular Expressions to return the
first match of:
/[ps]:\/\/([^\/]*\.)$\/?

Not sure on the \/... you might also try:
/[ps]://([^/]*\.)$/?
Both would match `p://.'
This should return the following for the following strings:
http://123.123.123.123/here.htm Returns:123.123 .123.123
https://mydomain.com/here.htm Returns:mydomai n.com
http://this.is.my.domain.name Returns: this.is.my.doma in.name


RFC3986, Appendix B, includes a Regular Expression for parsing URIs
that you could use.

However, you better configure your server accordingly so that it
responds with a 3xx status code, probably 301 or 302, and a
Location header that indicates the new location. Works everywhere
while your approach requires client-side script support. See also
<URL:http://www.w3.org/QA/Tips/reback>.
PointedEars
Nov 29 '05 #6

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

Similar topics

3
6536
by: Sean Berry | last post by:
Hi there. I am relativly new to Python CGI and need a question answered. I have made custom 404 error pages and have them in various web directories. I have not been able to figure out a way to have apache use a file not within it's own home directory, so I was going to have a .py file in cgi-bin forward the user on to the correct error page.
3
3899
by: Paul | last post by:
I'm not getting the results I want when I use Response.Redirct in a ASP page. I enter this line of code in a asp page from domain1.com. Response.Redirect "http://www.domain2.com/VDIR2/table.asp" & "?PubID=" & PubID & "&PubName=" & PubName The query string is data to open a DB. the page displays
2
7799
by: Robert Gordon | last post by:
I now realize I probably should have tried posting this on the IIS board first.. I am running OWA 2003 Server as Front End server to my Exchange 2000 native domain. The FE server is secured by a 128 bit SSL cert. The OWA 2003 server is running on Windows 2003 server in a Windows 2003 native AD domain. At present, the server is configured so that user's have to specifically go to the URL httpS://myserver.company.com in order to access...
3
1873
by: Hans | last post by:
Hi there, I have a number of domain names and they all point to the same IP address. I would like to redirect to a specific folder, based on the domain name used to access the site. For example. www.root.com - points to the main default page. www.otherroot.com would need to use the default page in a specified folder. My ISP is not able to help here by allocating new IP addresses to the subfolders of the main site. Something to do with...
11
2166
by: Stephen | last post by:
I was wondering if someone can help me with an web application design problem. I have a aspx page which builds up an arraylist called addresses and outputs the values in the arraylist items to a datagrid. I am using the viewstate object to store the Arraylist items on the page on postback. My PROBLEM is that I need to redirect the user to a new aspx page and on this new page i need to be able to access the items in my arraylist. Is this...
0
1701
by: WebHouse.Co | last post by:
Hi Sir I'm in my 2nd year in M.Sc. degree & I made a project about the powerful tools SQLXML 3.0 & updategram, so I made a list of programs which r they so similar to the example that using updategram with ASP That exist in the documentation of the Microsoft SQL Server XML Tools as the following page: Sample ASP Application
3
2484
by: MBW | last post by:
The following code is for a simple server/client asplication that allows the user to toggle between serve and or client modes and send/recieve a message however i am getting an Attribute error on my entry widgets when I try and call get() to get the port and ip address from those fields, I'm sure it's something simple I haven't grasped... #START from Tkinter import * from socket import *
3
2795
by: Calvin KD | last post by:
Hi everyone, I don't know if there's anyone out there is having the same problem. My DotNet 1.1 version uses FormsAuthentication.RedirectFromLoginPage() method to take user from the Login page to the Welcome page. My folder structure is as follows: Root Dir bin images secure Welcome
3
5499
by: Alan Silver | last post by:
Hello, Sorry if this is a stupid question, but I can't really see much difference between these tow methods according to the scant info in the SDK. Could anyone enlighten me? TIA -- Alan Silver
10
9014
by: Eirik Eldorsen | last post by:
How can I 301 redirect www.example.com/default.aspx to www.example.com without using ISAPI filters?
0
8829
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8508
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8608
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7341
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6172
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4164
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1962
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1627
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.