Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

The opposite of fURL::makeFriendly()

posted by gill 8 years ago

Is it possible to know the real URL of a web page (on the web, not mine), despite of some "fURL::makeFriendly" or routing ?
Actualy, I've got a problem of relative URL. Here's an example:

EDIT : wasn't a good example (there are "absolute relative URLs", too... : "/login.php" )
But the question remains...

All this doesn't seem very "friendly" for me ;-)
Is there a solution ? Thank's in advance.

The term "friendly" means it is user-friendly to type in and read. Instead of This%20is%20my%20page%21, you would use this_is_my_page.

Normally when using fURL::makeFriendly(), you are going to want to pair it with an identifier that does not get mangled, such as a database id. So your URLs will commonly look like /users/20-will_bond and you look up the user by the 20 and not the will_bond part.

If you do need to look it up and want a friendly URL, you can use the strategy of storing the friendly version of the URL in the database with the real name and then using the friendly URL column in your database to do lookups.

I hope this helps.

posted by wbond 8 years ago

Thanks. I knew this, for our own website. My question was for the other sites on the web. The "friendly URLs" with many slashes perturb some algorythms that need to parse the URL and analyse it.

(ex : "/users/20-will_bond" doesn't mean "the page '20-will_bond' in the directory 'users' ")

I managed with this, but I wonder if it'll be exhaustive...

posted by gill 8 years ago

I see what you mean. You are trying to come up with a way to parse other URLs. In this case I would probably start with a short list of patterns and then add more as you run into data that. Something like this is probably a good place to start:

# Matches things like /users/20-will-bond
^(.*)/(\\d+)-([^/]+)$

# Matches things like /users/20/will-bond or
# /people/20/will-bond/favorite/10/flourishlib_com
^(.*)/(\\d+)/([^/]+)$

Or perhaps instead you could write something that would split on / and then try to make pairs of data.

Either way you are probably going to need have a person at least analyse some example URLs from a site to establish the semantic meaning of the elements.

posted by wbond 8 years ago

Thank you, for these ideas !

Hmmm... so, there's not a unique simple solution. Hopefully I have a model to compare with the new URL, until I'm looking for successive pages, that are logically similar.

Thank's again :) !

posted by gill 8 years ago