DotNetNuke Custom Error Page, 404 Page Not Found Redirection

Often, DotNetNuke users never bother about URL issues which actually has a great impact on SEO especially your site is very old which has many old links from other websites and you have too much content to manage.

Even which the URL rewriter module like URL Master from ifinity or PageBlaster Module, they still have their limitation. Here, I’m going to talk about the new trend on URL redirections and general practice and DotNetNuke Method.

If you start from a fresh DNN new Website, you have nothing much to concern on the old url from the past. If you somehow migrate your website from a non-DNN to DNN website, you’re pretty much in worst case scenario. To cut it short, the best url redirection is to use 301 soft redirection. So what is 301 Redirection has to do with DNN?

301 Redirection

How to do 301 Redirection without touching IIS? Simplest way is to use URL Master from ifinity. One thing that you should always remember to do is: COPY DOWN THE OLD URL OF THE PAGE/CONTENT BEFORE YOU DELETE IT! Most of the people deleted the page and forgot which url need to be redirected.

If you need to change the URL of a page as it is shown in search engine results, we recommended that you use a server-side 301 redirect. This is the best way to ensure that users and search engines are directed to the correct page. The 301 status code means that a page has permanently moved to a new location. —From http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=93633

In ASP.NET There is no need touching the IIS to do 301 Redirection, so do in DotNetNuke.

To sum up, just do redirection whenever you delete or move the page location.

*Remember NOT to Redirect all the pages into same page like home page. You will be penalized by Google and having this message: “Too many redirections to single URL.” in the Google Webmaster Tool, and yup! the page will be de-indexed.

404 Page Not Found

So how to make a Custom Error Page for DotNetNuke? If you Google around, people will tell you do to IIS to do redirection. WTF? How am I going to do it in Shared Hosting then? The answer is, with Control Panal like Plesk, simply go to “IIS Setting” or “Custom Error Page” and type in the destination URL of your custom made error page and it is done! But that is stupid way.

By using the method above, all of your applications in the server will be redirected to the page! Since we only need to redirect 404 page in DotNetNuke right? Here comes the web.config file. To explain a bit further, DotNetNuke has it own Error Page in the root of DNN installation already which is ErrorPage.aspx. That file is actually trigger only when your DNN has configuration errors like failed to connect to database, module crashed or DNN installation failed. Most importantly, it has a ugly design that doesn’t match your website!

So, the easiest way (I never thought it is that easy, those ‘experts’ in DotNetNuke’s forum always goes too far for a simple solution) is as above:

How to make Custom 404 Error Page in DotNetNuke?

1. Create a page in your DotNetNuke and choose a skin and container that matches your design. Yup! Just like how you create a normal page as always.

2. Access to your DNN root files via FTP. Find your Web.Config File, download it and open using notepad.

3. Find (Ctrl+F) this line: <customErrors mode=”RemoteOnly” />
and replace it with ”
<customErrors mode=”RemoteOnly” defaultRedirect=”/Whatever-you-like.aspx” />

The mode attribute can be one of the following:
* On – error details are not shown to anybody, even local users. If you specified a custom error page it will be always used.
* Off – everyone will see error details, both local and remote users. If you specified a custom error page it will NOT be used.
* RemoteOnly – local users will see detailed error pages with a stack trace and compilation details, while remote users with be presented with a concise page notifying them that an error occurred. If a custom error page is available, it will be shown to the remote users only.

So, if you’ve already created a page called “/Whatever-you-like.aspx” in first step, then just put it inside “defaultRedirect”. And you may try to typed in wrong URL to visit your website, you should see this: http://www.example.com/Whatever-you-like.aspx?aspxerrorpath=/wrong.aspx

Remember that you can redirect the 404 Error Page to other website also, in this case, just type full url with http:// in inside the “defaultRedirect” attribute.

The best practice is to include your website navigation menu, sitemap and search box for the visitors that fall into this page so that they will not think that your website is broken or else. Therefore, try to match the DotNetNuke 404 Error Page same with your main design theme.

Furthermore, you can add Google Custom Error Widget (You can get your own custom code in Google Webmaster Tool) to show a search box which suggested links for visitors. Sadly, it seems that Internet Explorer is not supporting it if you’re using it in DotNetNuke. To be precise, the widget is still in beta and not quite ready for Dynamic websites.

One last thing, don’t forget to change the CustomError in web.config during DotNetNuke upgrade.

Hope this post solve your doubts and confusion in DotNetNuke Custom 404 Error Page. No need to change IIS setting! (Especially if you’re using Windows server 2008, most of the setting can be done within web.config)