Click to See Complete Forum and Search --> : making url "prefix" dynamic on a webpage


chris32680
08-14-2008, 01:18 PM
Hi all,
I tried googling for this and wasn't able to find anything...but that's probably because i'm not exactly sure of the right wording to search.

Here's the situation.
We produce a browser based software package that our company uses and that we sell to another company. We each have our own webserver to host and the backend is an oracle DB.

each of our webservers obviously have their own urls...

www.company1.com/whatever/...
www.company2.com/whatever2/...

One of our web developers produced a very nice menu bar that we're implementing and since it's static html we decided to not try and code it into a pl/sql stored procedure like we do most of our other web applications.

This menu bar has lots of links and a couple forms to perform some actions on each clients' databases.

The problem we're running into is that since it's not a stored procedure, we can't just use the oracle owa_util package to retrieve the url "prefix" (ie www.company1.com/whatever/) so that each site's links point to the correct location.

Is there a way where once you're "in" a site, to not have to put the entire url prefix on every link?

or maybe it's a javascript solution to actually change that portion of the url?

Any ideas or help would be appreciated!

Thanks a ton.

Chris

gil davis
08-14-2008, 01:38 PM
Maybe I'm missing something, but if the links are all relative, they wouldn't need to be dynamic.

Once you are "in" a site, drop the absolute approach and use relative links. That way if someone changes the structure of the site, it won't break your links.

Direct:<a href="http://www.company2.com/whatever2/...">
Relative:<a href="...">

chris32680
08-15-2008, 07:29 AM
Hi Gil,
Thanks for the response. Unfortunately that doesn't actually work for us. And since I'm fairly new at this and not real knowledgeable on the ins and outs of web servers, i'm probably not going to be good at explaining this, but...

we keep all of our image files in the location
www.company1.com/images

and the "whatever' portion of my sample url is actually used to point the webserver to the correct database on our db server.

so when we just make the links relative..instead of getting
www.company1.com/whatever/
it's only assuming
www.company1.com

meaning we have to derive the "whatever" portion somehow.

does that make any sense? (because i'm not sure it does to me :) )

OctoberWind
08-15-2008, 08:30 AM
You could probably make use of the <base> tag.


<base href="http://www.company1.com/whatever/" />


This sets a "starting point" for all the relative links on a page, regardless of what the existing URL is.

This ignores absolute paths, so you can still use external links or links to www.company2.com if needed.

Declan1991
08-15-2008, 09:50 AM
The base tag is deprecated, you can use use relative paths.
../images
will access
http://domain.com/images
from
http://domain.com/anotherdirectory/

Another option is to use / which means the root directory, so /images will do the same thing in this example.