MOVED AND MISSING WEB PAGES

Anyone who has been creating websites for more than five minutes has had to deal with pages that can't be found, pages that have moved, and pages that have been renamed. Various strategies exist for dealing with these constants in web development, but Umbraco provides some very simple and flexible methods for dealing with and managing these ever-present conditions.

404 Pages

Umbraco provides a very simple way to specify the page to be displayed when a 404 (page not found) error is encountered. In the /config/umbracoSettings.config file, set the error404 key value to the ID of the Umbraco node to use as your page to display when a 404 error is encountered. A good practice is to create a helpful 404 page that contains site navigation and perhaps a search form for your site. When your site visitors encounter this, as opposed to a generic web server 404 page, they are much more likely to find the page they had originally intended to find.

<errors>
  <error404>1010</error404>
</errors>

The page specified in the error404 key will apply to all sites within your Umbraco instance, regardless of the culture settings for each site. When you have multiple sites targeting different culture variants you can specify a unique page to be displayed for each site by setting the value of the associated errorPage key. The attribute culture defines which culture, and therefore which site, the page applies to. The culture value “default” indicates the key for sites that do not have an associated errorPage key.

<errors>
  <errorPage culture=“default”>1010</errorPage>
  <errorPage culture=“en-US”>2001</errorPage>
</errors>

Page Redirects

Umbraco provides several methods for handling page redirects when pages have moved or been renamed. One of the most flexible methods is to use the built-in URL rewriting feature provided by Umbraco's inclusion of the UrlRewriting.Net libraries. You create a redirect rule using UrlRewriting .Net by creating entries in the /config/UrlRewriting.config file. You have many options when using this method, all of which you can find at the project's website (www.urlrewriting.net). A sample 301 (permanent) redirect using UrlRewriting.Net follows:

<add name=“301ReDirect”
           redirectMode=“Permanent”
           ignoreCase=“true”
           virtualUrl=“^~/OldSection/(.*).aspx”
           destinationUrl=“~/NewSection/$1.aspx” />

In addition to using UrlRewriting.Net and the associated entries in the /config/UrlRewriting.config file, Umbraco also has two built-in methods to manage page redirects. Both are enabled by creating Document Type properties with specific names and data types. Both enable 302 (temporary) redirects and, as such, are well suited to use by landing pages and content likely to be updated continuously. With both of these Umbraco redirect methods, the redirect will only occur if a value is supplied for the Document Type property, so you can safely create these properties for your document types and use them only as needed.

Using umbracoRedirect

To use umbracoRedirect, follow these simple instructions:

  1. Create a property with the alias umbracoRedirect for the document type your page is using.
  2. Select the Data Type of Content Picker.
  3. Save your change.
  4. From the Umbraco Content section, select the page from which you want to redirect and then set the value of the umbracoRedirect property by selecting the page to which you want to redirect.
  5. Save and publish your changes.

The next time a site visitor loads the original page, a 302 redirect message is sent from the web server and the new page loads. With umbracoRedirect, the URL also updates in the visitor's browser.

Using umbracoInternalRedirectId

To use umbracoInternalRedirectId you follow the same procedure as with umbracoRedirect, except you should set the alias of the Document Type property to umbracoInternalRedirectId. In the case of umbracoInternalRedirectId the site visitor's browser will load the new page with a 302 redirect message sent from the web server. In this case, the URL will display the original URL in the visitor's browser.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset