Url Log

May 22, 2013 at 5:48 PM
This is getting really interesting. I was thinking of rolling my own for the Blog module, but it's much better if we can keep this in the Url Provider. So now my question is: how should I leverage this as module developer? Let me sketch the problem for the blog module.

The blog module created permaLinks when a post was added. These were fine as long as you didn't move the page or change your portal alias. Plus: they were not very pretty. So in essence the idea of storing permaLinks in the module was kind of handicapped by the way DNN works.

Now the blog module will generate these links on the fly. This means that when you rename the page or move your site (or change the post title) you'll still have an issue with url rewriting.

So my challenge is now 2 fold. For the newly generated urls: what to do with renamed posts? I guess your module picks up that the title changed from the change in the UrlRule. Right? And then you record the change I guess. So that would be great. Now, how about keeping track of page changes for the module? Is that possible?

Secondly: what is the best approach for legacy urls. If they even get to the new blog module they will include "EntryId=xyz" to point to the post. Now it will be "Post=xyz". Can I tell the url rewriter about this without the admin having to do that by hand?

Best,

Peter
Coordinator
May 22, 2013 at 8:11 PM
Url logs track the real urls requested by browsers (and search engine spiders) to find problems like :
  • status 404 : we missing a redirect ?
  • status 301 : why this redirect is present for a url we redirct a long time ago
  • duplicates : there to urls that are rewrited to the same internal url -> duplicate content, that not good for SEO
Answers to your questions
For the newly generated urls: what to do with renamed posts?
redirect the old url to the new url
I guess your module picks up that the title changed from the change in the UrlRule. Right?
yes
And then you record the change I guess.
No (yes in the url logs, buts its only for trouble shooting)
So that would be great. Now, how about keeping track of page changes for the module? Is that possible?
At the moment a url provider can generate redirects on its own. So if stores the history of the post title, you can generate redirect for old titles.

In the future, UrlRules, wil be stored in the database (the database table is already present in v 0.2 for custom redirects). And then a will have the full history of the urlrules. Then i will automaticaly generates redirect for url corresponding to old urlrules to then latest urlRule. This will work when you rename a blog post title or a page name.
If you move the module to a other page, i will give the possibiliy the user to create manualy a Tab Redirect Url rule. (Otherwise a will have to track moduleid in the rules, i had not considered this yet).
If you add a portal alias, i think the standard dnn alias redirections will work.
If you rename a alias, then you have to make a custom redirection witch just replace the alias in the url. Actualy not possible with the openurlrewriter custom redirects. But its possible with IIS Url Rewriter Module.

Secondly: what is the best approach for legacy urls. If they even get to the new blog module they will include "EntryId=xyz" to point to the post. Now it will be "Post=xyz". Can I tell the url rewriter about this without the admin having to do that by hand?
yes, its actualy possible.
you have to generate in addition of each rewrite urlrule , a redirect urlrule (an exemple is present in the ctlUrlRuleProvider)
Source of ctlUrlRuleProvider

For exemple this rule :

var rule = new UrlRule
        {
            TabId = -1,
            RuleType = UrlRuleType.Module,
            Parameters = "ctl=" + ctlName,
            Action = UrlRuleAction.Redirect,
            Url = "ctl/"+ctlName,
            RedirectStatus = 301
            //RedirectDestination = ctlName
        };
if the url contain the "Url" we redirect permanent (301) to the url of the rewrite rule with same parameters.

if you specify the "RedirectDestination" it just replace the "Url" (of the urlrule) with the "RedirectDestination"

This exemple redirect www.mysite.com/mypage/ctl/terms.aspx to www.mysite.com/terms.aspx
and this for all pages.
TabId = -1 is special for terms, privaty, login, register pages because there are internaly traited by the rewriter (this was already the case in the standard dnn urlrewriter)
May 23, 2013 at 7:36 PM
Thanks. I'll have to study this a bit to see what is the best way forward for the module.

Peter