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

  • Home
  • SEARCH
  • 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 856817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:17:49+00:00 2026-05-15T08:17:49+00:00

First of, I’m doing this for a web crawler (aka spider aka worm…) Given

  • 0

First of, I’m doing this for a web crawler (aka spider aka worm…)

Given two strings (base url and relative url), I need to determine the absolute url.
It is especially confusing when it comes to “SEO friendly” crap, such as:

Base url: http://aaa.com/january/15/test
Found url: /test.php?aaa

How would I know that the above aren’t folders or not?
Eg; the absolute path would be:

http://aaa.com/january/15/test/test.php?aaa

Or:

http://aaa.com/january/15/test.php?aaa

?

The confusion stems from whether there is an index in action or not. “/test/index.php” or “/index.php”?

  • 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-15T08:17:50+00:00Added an answer on May 15, 2026 at 8:17 am

    You can’t solve this problem by examining only the URL.

    You say you need the absolute URL given a base URL and relative URL. The full URL is the concatenation of the base URL and relative URL. As you’ve seen, knowing this doesn’t help one bit.

    http://example.com/directory/index.php and
    http://example.com/directory/ can legitimately refer to two different resources.

    http://example.com/directory/index.php and http://example.com/directory/foo/bar/baz.php can legitimately refer to the same ultimate resource.

    In the second above example, which is the canonical URL? This is not something that can be necessarily computationally determined. The canonical URL is the one you choose to be the canonical URL.

    You’re actually facing two problems here:

    1. When do two different URLs refer to the same resource?
    2. Which URL is the canonical URL?

    1. When do two different URLs refer to the same resource?

    This can’t be determined by comparing URLs in any way. This can only be determined by comparing the resource itself i.e. the content and the HTTP headers.

    ETag – http://en.wikipedia.org/wiki/HTTP_ETag

    In short, the ETag is an HTTP header that is unique for a resource. Its intent is for cache validation i.e. Is the content I have in my cache the same as the content at http://example.com/content?

    Two identical resources, at least from the same host, will have the same ETag header value. Use this if possible (not all web servers will return an ETag header).

    HTTP header and content comparison

    When are two resources identical? When the content type and content are the same.

    Compare the content type using the Content-Type header. Comparing the content itself is a simple case of string comparison.

    If you’re storing properties of previously-found resources and comparing these to newly-found resources you don’t need to consider the full text of the resource for the purposes of comparison – a hash will do.

    As far as PHP is concerned, the HTTP extension will give you all you need with a very convenient OO API for examining the HTTP headers and full content of a resource. The md5() function is one option for generating a unique hash. There are others.

    2. Which URL is the canonical URL?

    Pick one and stick with it. By default one URL is no more canonical than another for the same resource. For simplicity, you might consider the shortest of two URLs to be the canonical form.

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

Sidebar

Related Questions

First time posting here, will try to be succinct. This is a classic 'can't
First of all, I am sorry if this question doesn't belong to SO since
First off, there's a bit of background to this issue available on my blog:
First let me say that I really feel directionless on this question. I am
First let me apologize a bit for the length of this post, it's mostly
First let me preface this question by saying that I'm fairly new to Javascript.
First post, but I've been lurking around this site for a long while now,
First of all, my table structure is something similar like this: CREATE TABLE Testing(
First of all, I know I asked a similar question before but this one
First off, apologies if this is a duplicate of an existing question. Wasn't precisely

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.