Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 863917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:23:22+00:00 2026-05-15T09:23:22+00:00

The situation: On server A we want to display content from server B in

  • 0

The situation:

On server A we want to display content from server B in line on server A.

The problem:

Some of the hyperlinks in the content on server B are relative to server B which makes them invalid when displayed on server A.

Given a block of HTML code that contains anchor tags like the following

<a href="/something/somwhere.html">Somewhere</a>

what would be the most efficient way to convert them to

<a href="http://server-b.com/something/somewhere.html">Somewhere</a>

There can be multiple anchor tags in the content, the one catch is that some might be absolute and I want to leave those as they are, I only want to prepend the domain of server B to the relative URLs

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T09:23:23+00:00Added an answer on May 15, 2026 at 9:23 am

    I wouldn’t do this in Java; I like to handle view-specific logic in the view layer. I’m assuming this block of code is coming from an AJAX call. So what you can do is get the HTML from the AJAX call and then do this:

    jQuery(html).find("a[href]").each(function(index, value) {
      var $a = jQuery(value);
      var href = $a.attr("href");
    
      if(!/^http:/.test(href)) {
         $a.attr("href", "http://server-b.com" + href);
       }
    });
    

    Or if you really want to do this in Java, Lauri’s answer will work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation where I want to use several server side controls, which
Current situation: Ubuntu 8.04 server edition (live server) Postgresql 8.3.7 (from standard repositories) Postgis
Common situation: I have a client on my server who may update some of
I have following Situation, Server A sends some data (HTML form) to server B,
We want to have our test servers databases updated from our production server databases
I want to build a backend application to push messages from server to android
I've rails 3 app which displays records from a DB into table. I want
SQL Server 2008: I've got a situation here in which I wish to read
I am stuck in weird situation. I want to upload photo from my iPad
What will happen when we are using Server.Transfer and want to do some task

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.