[TriLUG] Default web root

ak dom akdom2001 at yahoo.com
Wed Jun 11 20:20:09 EDT 2008

>  For instance, I have two servers, east-coast.example.com and
>  west-coast.example.com.  ( I know that there are much better ways to
>  resolve the example problem, but reality isn't really an example. )
>  I am trying to serve all pages from data that is only in the west-coast
>  server.  Therefore, a URI like "href=/tets1/image1.png" would be
>  acceptable on the west-coast server, but should read:
>  "href=http://west-coast.example.com/tets1/image1.png" on the east-coast
>  machine.

Are you saying you want to be able to set a prefix to create absolute URI's, directed at a different server, out of what would otherwise be relative URI's?  I don't know if I completely understand the issue. Are you wanting the "href=/tets1/image1.png" to tell the user's browser to go to "href=http://west-coast.example.com/tets1/image1.png"?  Or do you just need the relative link on the east-coast server directed to content located on the west-coast server?  Is this content load-balanced between the servers, possibly on either, or just statically on one of the two servers?

If you have content which statically sits on one server and don't necessarily need the user's browser to show the full URI in the href, you could just do a rewrite map.... I'd take a look at the top section of http://httpd.apache.org/docs/2.0/rewrite/rewrite_guide_advanced.html or the other rewrite guide can be found at http://httpd.apache.org/docs/2.0/misc/rewriteguide.html .

Or you could theoretically do something with server side includes... http://httpd.apache.org/docs/2.0/mod/mod_include.html .

The only way I could think of doing this with javascript would be to build a script around document.URL (the path the page was sent from) which grabs "relatively formed" urls out of the page and prefixes them with the needed server when not actually on it... though I think a RewriteMap would be cleaner.

If you find a cool little "prefix meta-variable" like you talked about which does easily, I'd be curious to hear what it is.

Alex Kesling


More information about the TriLUG mailing list