If your instance of Kentico CMS is running on a server with IIS 7 or higher installed, the procedure is quite simple - it consists only of adding and modifying a few keys in your project's web.config file.
For it to work, you need to modify the system.webServer section of your web.config file by adding the first highlighted line and changing the opening <modules> tag to the second highlighted line in the code example below.
<system.webServer> ...
... </system.webServer> |
With these modifications in your web.config, you can proceed to configuring the extensions in Kentico CMS administration interface. You can also perform some additional configuration as described below.
A custom page-not-found page for non-CMS pages can be configured by modifying the customErrors section, as in the following code sample:
<customErrors defaultRedirect="~/CMSMessages/error.aspx" mode="On"> <error redirect="~/cmsmessages/pagenotfound.aspx" statusCode="404" /> </customErrors> |
You can also add the following key to the AppSettings section, which ensures that URLs remain the same even after postback.
<add key="CMSUseExtensionOnPostback" value="false" /> |
If you are using trailing slashes (enabled by the Use URLs with trailing slash option in Site Manager -> Settings -> URLs and SEO), you can use the following extra key to have only extensionless URLs ending with the trailing slash. URLs ending with an extension are rendered without the slash when the key is used.
<add key="CMSUseTrailingSlashOnlyForExtensionLess" value="true" /> |
Using the cmspages/handler404.aspx special page (obsolete)
Due to backward compatibility, you can also enable custom URLs by configuring your IIS manually. It is not recommended now as it is obsolete.
If you receive the Lock violation error during the procedure, try the solution described here.
The setup procedure on IIS 7 is the following:
1. Open Start -> Control Panel -> Administrative Tools -> Internet Information Services (IIS) Manager.
2. Select your website from the tree on the left and open the Error pages section.
3. Right-click the 404 error and choose Edit Feature Settings.
4. Enter the following values:
• | Path: enter the URL of the cmspages/handler404.aspx page according to your application's URL. Example: if you run your web project in virtual directory /kenticocms, you need to enter /kenticocms/cmspages/handler404.aspx |
• | Path type: Execute URL |
Click OK.
5. Now right-click the 404 error again and choose Edit from the context menu.
6. Select Execute a URL on this site and enter the same URL that you entered in step 4. Click OK.
7. Go back to step 3 and repeat the same procedure for the 405 error.
8. Click OK on all dialogs to save the changes. It's not necessary to restart the application.
Setting up the .html extension on IIS manually (obsolete)
The following approach is also possible, but not recommended and considered obsolete now. To use the .html extension, go through the following steps:
1. Run IIS Manager .
2. Select your web.
3. Open Handler mappings.
4. Click to Add managed handler... .
5. Enter the following values:
• | Request path: *.html |
• | Type: System.Web.DefaultHttpHandler |
• | Name: HTML |
Click OK.
Page url: http://devnet.kentico.com/docs/devguide/index.html?custom_url_extensions_iis7.htm