Last post May 10, 2006 05:10 PM by rfurdzik
Apr 12, 2005 04:57 PM|haidar_bilal|LINK
Apr 12, 2005 06:07 PM|Scott Mitchell|LINK
Apr 13, 2005 08:01 AM|haidar_bilal|LINK
It's been a while since I wrote that article (for those new to the thread see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/urlrewriting.asp), but IIRC the rules engine used regular expressions, no? So couldn't you use a wildcard in the regular expression used to match the incoming URL?
Apr 13, 2005 10:40 AM|Scott Mitchell|LINK
Apr 19, 2005 03:20 PM|SomeNewKid|LINK
The code from Scott's article can be updated to use wildcards. My equivalent of Scott's "LookFor" rule allows for wildcards (*) in place of both filenames and extensions:
/articles/url-rewriting.* (to match .pdf downloadable version of the above)
/articles/* (to match a request for any article)
/articles/*.* (to match darn near everything)
What I do is first order the rules from the most specific (no wildcards) to the least specific (two wildcards). Then I loop through the collection of rules. Because of the ordering, a specific match will be found before a non-specific match, which is what
A filename wildcard is replaced with the following regular expression pattern:
An extension wildcard is replaced with another regular expression pattern. I won't provide it, as it is linked to a certain URL style that I am using.
Having replaced the friendly wildcards (*) with regular expression patterns, the remainder of Scott's code would work without change.
Try it and see for yourself.
May 08, 2006 07:22 PM|rfurdzik|LINK
I love the article! Good job!
I would like to rewrite any Link with query string on my site. I was thinking about this rule:
1) Original URL - ~/Default.aspx?CategoryId=10
2) Rewritten URL ~/categoryID/10/Default.aspx
The above would be only executed as the last rule (if no other rules found), to make the site Search Engine friendly. So If there is Rule let's s say for Category=10, then that rule would be used instead...
The number of possible parameters would be unlimited. Any link could be converted to this form...
Do you think this can be done easly using your URL rewriter? Can I implement this using Regex and place the last rule (not sure about regex here and SendTo). Maybe I could just modify the engine and put all to the array and than parse? This would be the
last step after all rules failed...
Wonder what your thoughts are...
May 10, 2006 05:10 PM|rfurdzik|LINK
The article is great but it does not address the issue with relative paths. If the rewritten URL has a different path than the originnal the relative links on the page will not work Is there a way to resolve this problem?
This is the link created on CSK catalog page:
It will become:
yet it should really be:
I have realized that the item template SHOULD USE the rewritten path, which is
http://localhost/csk11/ instead of using the original path