A former twenty something in technology

Removing the .aspx from your DotNetNuke URL

DotNetNuke ships with a URL provider that over the years has gone through several updates in how it can handle URLs Original Method - Default.aspx?TabId=52 Second Version - /Home/TabId/52/Default.aspx Human Friendly (Current Default) – /Home.aspx The new human friendly is great but still requires that the user append the .aspx to the end of the page names. Case Study Lets say you have a business card or promotion and you want to advertise a specific page on your site that people could actually type in “www.domain.com/promo” Typically what you would do is FTP into your DotNetNuke root directory, create a folder called promo and then create a default.htm page to redirect to www.domain.com/promo.aspx Rewriting the URL With IIS7 and Url Rewriting you can now add some lines to your web.config file and handle urls without the .ASPX extension. Below is an example of such a rewrite rule and you will place this inside of your node.

    
        
          
          
            
            
            
          
          
        
    

This code works by first making sure that a file or directory with the /promo does not already exist. If it does then the physical file will take precedence over the rewrite rule. Second it will then take the domain url and append the .aspx to the end if it does not exist. So when you type in /promo behind the scenes it is serving up the page /promo.aspx. This is done without redirecting or changing the url. Now all your URLs in DotNetNuke can be simple and even more pretty. Update 1/25/2012: Here is an alternative version if you want to do 301 redirects to the page name vs rewriting the url.

    
        
          
          
            
            
            
          
          
        
    

 
Comments

I have tried same and it works perfectly but a new problem occurs that when I try to add module to page in admin panel of dotnetnuke 7.0 it gives error.
Do you know how to solve it ?

Sukhbir SIngh

You could use IIS UrlWrite rules within your web.config to modify the behavior and rewrite any url.

https://gist.github.com/jsheely/5949562

Or you can wait a couple weeks until DNN 7.1 is released where no extension will be the out of the box setting. Check out Bruce Chapman’s post for more details

Leave a Reply