smcculloch posted on January 10, 2006 21:08
Last night, I posted a blog entry showing some of the real friendly URL functionality I have been working working on.
Immediately, there were some comments, and I'd like to address some of those here.
Excellent Scott. How's it handle page names being the same (e.g. Say there a page called Humans under both the Races and Classes)?
Great question, both urls would look like:-
- friendly.ventrian.com/races/humans.aspx
- friendly.ventrian.com/classes/humans.aspx
To understand why the above would be OK, we must first understand how the rewriter works.
The first goal of the rewriter is to identify the portal we are working with. To do this, it breaks up the URL and begins to test for a valid portal alias, so the list of tests would be as follows:-
- friendly.ventrian.com (Portal alias found, stop looking!)
If a portal alias wasn't found, it would keep looking as follows:-
- friendly.ventrian.com (Portal Alias not found, keep looking down a folder)
- friendly.ventrian.com/races (Portal Alias not found, keep looking down a folder)
We are out of folders now, so panic and just call the old rewriter to do its work.
The second goal of the rewriter is to identify the page we are working with. To do this, lets look at what is left over from the following url.
- friendly.ventrian.com/races/humans.aspx
The portal alias we already know, (friendly.ventrian.com). The left over part is races/humans.aspx. Now we have the left over part, loop through the list of pages in the portal, and look at the tabPath variable. The tabPath variable stores the path back to home, in our case, it stores //races//humans. So with a bit of manipulation, we can find a match and retrieve the tabID so we can serve up the page.
If the page is not found in the portal, it keeps looking down the folder structures for further portals (possibly child portals with a matching tabpath).
So its for this reason, the following would work:-
- friendly.ventrian.com/races/humans.aspx
- friendly.ventrian.com/classes/humans.aspx
However, the following would not work (if there were 2 pages called humans.aspx under races).
- friendly.ventrian.com/races/humans.aspx
- friendly.ventrian.com/races/humans.aspx
The first page found in the list of pages within a portal would get returned each time, rather then the unique instance. We can add error checking for this later.
I noticed that it does not allow 'friendly' parameters so you could have http://friendly.ventrian.com/Races/Dwarves.aspx but not http://friendly.ventrian.com/Races/Dwarves.aspx?AlbumID=367-1
or
http://friendly.ventrian.com/AlbumID/367-1/Dwarves.aspx
Currently, it does not do this as you have found out. But I am looking to get it working with an enhancement. If you read the above question, I would need to take the parameters out of the url, and then look at the tabpath of what is left. It should be achievable.
Now for my own question, can you have multiple urls point to the same page?
I'm glad you asked that, the next enhancement I am making will allow you to add additional urls to a page to make it resolve. (Kind of like how portal alias's work for a portal). So when resolving a url, it would look at this map of pages first, then the tabpath, then call the old rewriter if it still can't find anything.