Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preserving the URL after a redirect?

Status
Not open for further replies.

LeeFarrant

Technical User
May 16, 2002
10
GB
I was browsing the web the other day and a website I had a look at redirected you to a different webpage but still preserved the original URL that was typed in the address bar on the browser (it didn't move or change at all) How is that possible? I would like to do something similar.

The reason I am asking is because of a note I posted earlier today about viewing a profile of my user like this

myweb.com/fred

this would have to be translated and redirected to mysite.com/profiles.asp?user=fred

but I want the URL address in the browser to stay showing

myweb.com/fred

Lee
 
One of the reasons to have the URL change to reflect the actual site location is so the remote user is assured he hasn't been hijacked somewhere else. In fact, that's a recent security vulnerability that's been publicized lately where a malicious site could provide a link, say for examle, to microsoft.com, but really have you on a copied page on its own server. (See - Until security patches come out, you can only trust sites you go to yourself, as it is difficult though not impossible to determine if a link is safe.) I know you did not ask about spoofing someone else's website but thought you should know why good intentions in a desire for neatness may not always work out.

Now, if you want your own site to display a simple address line, perhaps someone else can help on that aspect of your question. One way might be for you to have a different directory for each account, but then you'd always be adding and deleting directories, duplicated ASP files, etc. If the "alias" concept is not allowed in ASP, perhaps CGI or PHP, etc. allows this?

dbMark
 
Are you wanting myweb.com/anything to be redirected to /profiles or just specific entries that you set up? If it is the latter then you can try something like this...

1. Create a /fred directory on your webserver.

2. Create a default.asp file in this directory

3. Put the following lines of code in default.asp
session("username") = "Fred"
server.transfer("/profiles.asp")

4. Put the following code in profiles.asp
username = session("username")

5. Repeat for any other users that you wish to set up.

Now when a user browses to myweb.com/fred it appears to them that this is where they are staying, but in the background the server is pulling content from profiles.asp!

Hope this is what you were looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top