140 likes | 978 Views
Webinar 10/21/2009. URL rewriting and processing in Kentico CMS. Martin Hejtmanek (CTO), martinh@kentico.com. Topics. Document name vs. alias What is an alias path? Document aliases and URLs Permanent vs. user friendly URLs URL priorities URL extensions / extensionless mode
E N D
Webinar 10/21/2009 URL rewriting and processing in Kentico CMS Martin Hejtmanek (CTO), martinh@kentico.com
Topics • Document name vs. alias • What is an alias path? • Document aliases and URLs • Permanent vs. user friendly URLs • URL priorities • URL extensions / extensionless mode • How does URL rewriting work? • Difference between Portal and ASPX page template processing • File processing and URLs • Wildcard URLs
Document name vs. alias • Document name – Nice and friendly name • Home • About us • Domů (czech) • بيتنا(arabic) – found on Google • Alias – Form of the document friendly for URLs and clients • Home • About-us (without spaces) • Domu (without punctuation) • Bayt (english pronunciation)
What is an alias path? • Document aliases connected with / • / • /Home • /Products/Phones-and-TVs/Nokia-9910 • /News • /News/News-1 • /News/News-2 • Selecting document by alias path (TreeProvider.SelectNodes) • /Home = Document “Home” • /News/% = All children under “News” document=> WHERE NodeAlias LIKE ‘/News/%’ • %/Best = Any document with alias “Best”
Document aliases and URLs • NodeAliasPath = Default document alias = Location in the tree • Alias path, all cultures of document share one • Created automatically from aliases on the path • DocumentURLPath = Alternative path for the document • URL path – Customizable per culture version • If defined, is handled as the main document URL • Defined automatically (based on document names on the path) • Defined by the editor (any path) • Document aliases (from in 4.0) • Any number of additional aliases (locations for the document) • All cultures / per culture • Document extension – Main / defined for aliases (.jpg, .gif, etc.)
Permanent vs. user friendly URLs • Permanent URL - Will work any time in future • /getdoc/eb1b5175-d7e6-479e-a19e-dbd6be035c16/home.aspx • Contains NodeGUID which identifies the document • Friendly URL (easily readable) – May not work in future if you change the document alias(es) • Based on Alias path / URL path / Aliases • /Home.aspx • /News/News-1.aspx • Friendly with configured friendly URL extension • /News/News-1.html • /News/News-1 (extensionless) • /Files/Home.jpg (CMS.File document with specific extension)
URL priorities • 1) Searched by URL path (if found, specifies also the culture) • 2) Searched by Alias path (uses current culture) • 3) Searched by Document aliases (uses current culture) • Wildcards (later)
URL extensions / extensionless mode • Settings -> URLs -> Friendly URL extension (works anywhere) • .aspxby default -> /Home.aspx • You can configure any extension, see documentation • .htm -> /Home.htm • Extensionless mode (friendly extension is empty) • (none)-> /Home • Other than default processed with the handler page in Kentico • ~/CMSPages/handler404.aspx • Document can override the default extension in its properties
How does URL rewriting work? 1) Request from client /Home.aspx?abc=def 2) AuthorizeRequest -> RewriteURL(…) does RewritePath to: 2a) Portal template /CMSPages/PortalTemplate.aspx?abc=def&aliaspath=/Home Page loads the controls dynamically from XML of the template 2b) ASPX template /<template path>?abc=def&aliaspath=/Home Controls are already on the page template defined with ASPX 3) Controls load their content using their settings or context values NOTE: With 404 handler, the IIS serves …/handler404.aspx?aspxerrorpath=/Home.aspx?…
Difference between Portal and ASPX • Portal engine (templates) • One shared physical template for all pages (dynamic) • All controls loaded dynamically and hierarchically • Completely built on Kentico CMS engine (can be developed through browser) • (control over visual inheritance) • ASPX page templates • Different physical templates for different pages • Content of the template is defined statically by the ASPX code • Development in Visual studio • Control over the entire page (can completely change the default page behavior) – Not really necessary in 99% of cases
File processing and URLs • GetXYZFile scripts • CMS.File – Accessing with same path as document • /Files/logo.aspx -> /CMSPages/GetFile.aspx?nodeguid=<guid>(document node GUID) • Other files • Document attachments - /CMSPages/GetFile.aspx?guid=<guid>(attachment GUID) • Object attachments - /CMSPages/GetMetaFile.aspx?guid=<guid>(metafile GUID) • Media files - /CMSPages/GetMediaFile.aspx?fileguid=<guid> (media file GUID) • etc.
Possible file URLs (based on settings) • Document files (CMS.File only) • Document path /Files/logo.aspx • Permanent document path /getdoc/<nodeguid>/<anyname>.aspx /CMSPages/GetFile.aspx?nodeguid=<nodeguid> • Document attachments (any document) • /getattachment/<nodealiaspath>/<filename>.aspx • /getattachment/<attachmentguid>/<anyname>.aspx • /CMSPages/GetFile.aspx?guid=<attachmentguid> • Meta files (object attachments) • /getmetafile/<metafileguid>/<anyname>.aspx • /CMSPages/GetMetaFile.aspx?guid=<metafileguid> • Media files • /getmedia/<mediafileguid>/<anyname>.aspx • /CMSPages/GetMediaFile.aspx?fileguid=<mediafileguid>
Wildcard URLs (new in 4.0) • Document /DisplayProduct • URL path (alias) /Products/{name} (doesn’t have to match alias path) • Translates as /DisplayProduct.aspx?name=<value> • /Products/Nokia-9110 /DisplayProduct.aspx?name=Nokia-9110 • More complicated wildcards /{country}/Hotels/{hotel}/Menu /Czech/Hotels/Grand/Menu /DisplayMenu.aspx?country=Czech&hotel=Grand • Similar to ASP.NET routing • Processed within the rewriting chain in matching wildcard found
Q&A • Now is the time for your questions • The webinar recording will be available on our new Partner portal and later on the DevNet.