Forum Discussion

Cindy_127211's avatar
Cindy_127211
Icon for Nimbostratus rankNimbostratus
Aug 16, 2006

Rewriting URI on HTTP Response

Is it possible to 'rewrite' a URI when a response comes back from a server?

 

 

What we want to have happen is the following:

 

 

The user types in:

 

 

http://www.website1.com/dir1/dir2/dir3/abc.jsp

 

 

We want to have the page servered back to the end-user; however, we want the following displayed in their browser window:

 

 

http://www.website1.com/

 

 

(i.e. we are wanting to eliminate the display of all of the subdirectories and the file name).

 

 

I've tried several different things, but none of them work.

 

 

1 Reply

  • Unfortunately what you are requesting cannot be done due to the HTTP protocol itself. If HTTP allowed for the URI to be returned as part of the response and the browser acknowledged that value then you would be all set. You could easily add this to a response header but the browser wouldn't know what to do with it. But, per the HTTP specs, the URI is only part of the HTTP Request and the browser displays the value of its last request.

     

     

    Now, if there are embedded url's in the payload (the HTML content) then you could modify those by modifying the HTTP::payload data, but I think you are getting at just changing the address bar.

     

     

    Sorry, I wish we could perform magic, but sometimes we are stuck with the limitations of the protocols...

     

     

    Wait, one thing just came to me. If JavaScript enabled you to modify the address field in the browser, then you could return a response header with the uri value you want to present, and then have some client side code change the address. But, I'm not aware of if this is possible. The closest thing I can think of is the "document.location.href" value but I don't know if this actually changes the address bar or not. Something to try at least...

     

     

    -Joe