Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

changing a relative url to an absolute url

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I need to change all the relative urls found on a webpage to absolute urls.

Now i know that if the webpage's name is "http://www.hello.com/index.html" then for every relative url found on the webpage, example "tree.html", i must append to it the hostname of the webpage, that is, "http://www.hello.com/tree.html"

But what if that is not the hostname it needs?
For example what if "http://www.hello.com" is a page that is part of the main page called "http://www.greetings.com" and therefore every relative url found on the "http://www.hello.com" page require the hostname of the "http://www.greetings.com" page.
How can I accomodate this?

I am using HttpClient and i am not sure if it does this automatically.

Any comments will be greatly appreciated

MJ
 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In general, relative URLs can save a lot of time & headache by making your website more portable. Where are these URLs, specifically, that need changing? In your HTML? Unless you're running a huge website (in which case you'd already have a better solution) I'd just do a quick search/replace on a by-file basis. Put careful thought into why you want absolute URLs, maybe your webpage just needs restructuring.
 
You have to be odd to be #1 - Seuss. An odd little ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic