Introduction
Many Sitefinity clients migrate static websites to Sitefinity. As a result, they might keep the domain name, but remove the HTML pages, for example, by creating .ASPX pages in Sitefinity. Pages from the old site might exist on Google © and when someone searches for your website, by clicking on the HTML page, it no longer exists. In this case, you need a URL redirect and this can be done by creating additional page URLs in Sitefinity, programming an HTTP Module, using Sitefinity's URL Rewrite engine, or adding a URL redirect to a static HTML page.
URLs and Sitefinity
By default, Sitefinity only handles one page extension at one time. You can have multiple URLs extensions for a page using the additionalExtensions property in the <cms> section of the Web.config. You can set the page extension for all pages using the pageExtension property in the same area. To customize this properties, follow these steps:
- Open the Web.config of your project
- Find the CMS tag
- Customize the section as shown below:
4. Login to your Sitefinity project
5. Click on the pages tab
6. Click on a page
7. Click on the properties tab on the right
8. Click more options
9. Add new URLs as shown below:
Redirection with Meta Tags - Creating the HTML Page
One advantage of this approach is that you can send a user to a
specific page when a certain page is requested, without having to alter the Web.config or create a HTTP Handler.
If you have multiple pages, however, this approach could be inefficient.
Here are the steps to perform a meta tags redirction
- Create an HTML page in the same directory with the same name as the old page, in your Sitefinity project.
- In between the head tags, add this code:
The link you see above is where the user will go, once the HTML page is visited. Here is the end result:
Creating an HTTP Module
This approach would allow you to redirect any request to a specific page. To implement this approach, follow these instructions:
1. In your App_Code folder, create a new class that inherits from IHTTPModule
2. In the Begin Request event, add logic to redirect the user as shown below:
3. In your Web.config, register your HTTP Module:
For more info on creating custom HTTP Modules,
please refer to this article.
Regular Expressions
Sitefinity includes a URL re-writer tool that uses regular expressions. Here is a code sample:
The rule is what the URL Rewriter should look fro in the URL. The <rewrite> attribute is what the new URL will be. For more info on using this tool, please refer to
URL Rewriting in our
User Manual.