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 8785731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:26:27+00:00 2026-06-13T21:26:27+00:00

I am trying to do some web crawling and I came across an issue

  • 0

I am trying to do some web crawling and I came across an issue of when to add a slash or not. I know that some sites do have it at the end and some don’t but entering the wrong one in the browser will just redirect you to the right one. Normalization would add the slash at the end but its going to cause a problem when trying to convert the relative URLs to absolute.

For example if a user selects an absolute URL http://stack.com/more but the actual (redirect) URL is http://stack.com/more/ and a relative url is index.html

Then doing URL newurl = new URL(url, relativeURL);

yields http://stack.com/index.html (non existant page)

when it should actually be http://stack.com/more/index.html(real page)

Doese anyone know a good way to correctly append the slash at the end?

  • 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-06-13T21:26:28+00:00Added an answer on June 13, 2026 at 9:26 pm

    If a relative URL starts with a /, it’s only relative to the root (the domain). So both

    http://stack.com/more/ + /index.html

    and

    http://stack.com/more + /index.html

    are correctly resolved to

    http://stack.com/index.html

    not

    http://stack.com/more/index.html

    In your example, it makes no difference whatsoever whether there’s a / at the end of more.

    The trick comes in when there’s no leading slash on the relative URL, e.g. index.html. When resolving those, you’re supposed to remove the last segment and replace it with the relative path. It would make a difference in that case, because

    http://stack.com/more/ + index.html

    resolves to

    http://stack.com/more/index.html

    but

    http://stack.com/more + index.html

    resolves to

    http://stack.com/index.html

    (index.html replaces more, because more is the final segment).

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

Sidebar

Related Questions

In my WebView am trying to download some files from some web sites but
I am trying to expose some Java web services so that I can interoperate
I have some web application that uses jQuery to send AJAX requests to server.
I am trying to develop some RESTful web services which have to access some
I have some Web API methods that I want to write unit tests for.
I'm working with some web services that have already been created and I need
I'm trying to consume some .NET web services using JAX-WS. I have generated the
I have been trying to connect to some web services using WCF but I
I'm trying to use R to grab some web data that requires OAuth authentication.
So I just recently bought some web hosting and I'm trying to get my

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.