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

Which is better to do client side or server side validation? In our situation
I created ATL COM-server in VC++ 2005. I want to realize some interface defined
I have an unusual situation to model in a MS SQL Server database: the
We've got a situation where someone messed up a Commit to our SVN server.
I have somewhat interesting development situation. The client and deployment server are inside a
Do T-SQL queries in SQL Server support short-circuiting? For instance, I have a situation
Situation: Site with content protected by username/password (not all controlled since they can be
I have a situation where I'm trying to build a web app which takes
I'm running into a weird problem and I want to know if it is
Okay. I'm having some conceptual issues with a WCF service i want to create.

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.