Link to home
Start Free TrialLog in
Avatar of Resna
Resna

asked on

Removing .APSX from URL

Hi Guys,

I'm finding it difficult to find a specific tutorial onlie to remove .ASPX from my URLs using URL Rewrite in the web config file.  There seems to be more than one way to do it, and I'm not used to Windows server plus my client is putting pressure on me :(

The site is running on:
Windows Server 2008
IIS 7
ASP.NET with .NET framework v2.0  
ASP.NET with .NET framework v3.0 & 3.5


The URL's are:
http://tbglearning.com/About-Us.aspx


How I would like the URL's [remove the .ASPX]:
http://tbglearning.com/About-Us

Could some one help me write the re-write code please

Many thanks

Resna
Avatar of Amandeep Singh Bhullar
Amandeep Singh Bhullar
Flag of India image

You need URL rewriter
http://urlrewriter.net/

URL rewriter is open source best rewriter
For few pages

you can use this

http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

If you have more number of pages or all the page you can go with AmanBhullar solution.
Avatar of Resna
Resna

ASKER

Thanks for the replies.

But the site is on a shared host.  And it seems you need to access to the IIS controls [which I don't have].

Any other ideas?

Many thanks

Resna
Sample Download: A sample application that I've built that shows using this technique with the UrlRewriter.Net module can be downloaded here.  http://www.scottgu.com/blogposts/urlrewrite/UrlRewrite_HttpModule1.zip

What is nice about this sample and technique is that no server configuration changes are required in order to deploy an ASP.NET application using this approach.  It will also work fine in a medium trust shared hosting environment (just ftp/xcopy to the remote server and you are good to go - no installation required).
For http://urlrewriter.net/ you do not need access to IIS.
I am using the same in my site
for http://forum.littlekrazy.com/
Avatar of Resna

ASKER

Thanks for the replies

Just to clarify:
I know nothing about ASP(x), Windows server / IIS nor re writing URLs no a Windows / IIS server

Craig_F:
The file you linked is the same as the one I've downdloaded from the URL Re Write site.
How do I install it and what is the rule to remove .aspx from the end of all URL's.  You say FTP/upload it do you mean the whole directory in the same folder.

At the moment in the web config you sent this is the re write:
  <rewriter>
    <rewrite url="~/products/(.+).aspx" to="~/products.aspx?category=$1" />
  </rewriter>

Which is not relivant to the site I'm working on.

The reiterate:
1. I would like to know how to install Urlrewriter.
2. What should the rule be to remove .aspx from the URLs

AmanBhullar:
When visiting your forum I see normall URLs, like the below:
http://forum.littlekrazy.com/default.aspx?g=topics&f=2

Many thanks

Resna

on my forums, user is always on the default page.
You can use the url rewriter to remove .aspx.

Check the example for using tool
http://dotnetguts.blogspot.com/2008/07/url-rewriting-with-urlrewriternet.html
http://www.tutorialsasp.net/tutorials/url-rewriting-in-aspnet-using-urlrewriternet/

you can explore it more
ASKER CERTIFIED SOLUTION
Avatar of Craig_F
Craig_F
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oops, here is the code snippet
// The requested URL
string strURL = Request.RawUrl.ToLower(); 
    
// If the page didnt exist, the IIS tries to send the visitor to 404.aspx, 
//this is where we intercept.
if(strURL.IndexOf("404.aspx") > 0) or if(strURL.IndexOf("404.aspx") < 0)
{ 
    // Scan the path for the keywords and rewrite the path to the preferred content
    if (strURL.IndexOf("products") > 0) Context.RewritePath("content1.aspx");
    if (strURL.IndexOf("sales") > 0) Context.RewritePath("content2.aspx");
    if (strURL.IndexOf("support") > 0) Context.RewritePath("content3.aspx");
}

Open in new window

Avatar of Resna

ASKER

I'm not being funny, but no one seems to answering my questions, nor my original question.

1. I would like to know how to install Urlrewriter.
2. What should the rule be to remove .aspx from the URLs

Many thanks

Resna
There is no installer of urlrewriter.
You need to donload the DLL files.
Place them in Bin folder and start using it in project

Have you checked the links
http://dotnetguts.blogspot.com/2008/07/url-rewriting-with-urlrewriternet.html
http://www.tutorialsasp.net/tutorials/url-rewriting-in-aspnet-using-urlrewriternet/

First Link explains step by step way of configuring and using the urlrewriting