In the above example, they provide a tutorial regarding how to remove the aspx extention to the URL. They say that this can be done also with other types of extentions.
In my case, I would like to rewrite all the .aspx and the .htm extention to all my files.
Since I am not really good in IIS Programming, I think that what I am not able to do at the moment is to set a correct rewriter.
In the above example, this is what they set in the rewriter section
The question is: what should I write there if I want all my .htm and .aspx (which are pages linked to a master page but are not dynamic) extensions to be removed?
Thank you so much in advance for the help you can give me.
In this way the URL rewriting can be accomplished by adding a list of URL that u want to rewrite without extension. However, this doesnt seem to be a confortable and quick way of progragmatically manage sites with lots of URLS because this would mean to
write hundreds of URLs which will probably cause errors.
In addition to this, from a SEO perspective, rewriting the above URLS can cause a decanonicalisation of the URLs, meaning that the same resource can be accessed at "page" and at "page.htm".
In order to avoid this, the best thing would be to perform http permanent redirect from page.htm to page with extension but, again, it's not really a progragmatic way of approaching that, at least I think.
Can you suggest better examples how I can progragmatically perform extensionless URLs with progragmatic http redirect from the pages with extension to the ones without.
Claudio7810
Member
57 Points
89 Posts
Using an HttpModule to Perform URL Rewriting - Extension-Less URL
Sep 16, 2011 04:49 PM|LINK
Hi All,
I am trying hard to perform url rewriting to get extensionless urls.
I am following approach N. 3 that you can find on this link http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
In the above example, they provide a tutorial regarding how to remove the aspx extention to the URL. They say that this can be done also with other types of extentions.
In my case, I would like to rewrite all the .aspx and the .htm extention to all my files.
Since I am not really good in IIS Programming, I think that what I am not able to do at the moment is to set a correct rewriter.
In the above example, this is what they set in the rewriter section
The question is: what should I write there if I want all my .htm and .aspx (which are pages linked to a master page but are not dynamic) extensions to be removed?
Thank you so much in advance for the help you can give me.
Claudio7810
Member
57 Points
89 Posts
Re: Using an HttpModule to Perform URL Rewriting - Extension-Less URL
Sep 16, 2011 05:19 PM|LINK
HI All,
I figured out how to do:
In this way the URL rewriting can be accomplished by adding a list of URL that u want to rewrite without extension. However, this doesnt seem to be a confortable and quick way of progragmatically manage sites with lots of URLS because this would mean to write hundreds of URLs which will probably cause errors.
In addition to this, from a SEO perspective, rewriting the above URLS can cause a decanonicalisation of the URLs, meaning that the same resource can be accessed at "page" and at "page.htm".
In order to avoid this, the best thing would be to perform http permanent redirect from page.htm to page with extension but, again, it's not really a progragmatic way of approaching that, at least I think.
Can you suggest better examples how I can progragmatically perform extensionless URLs with progragmatic http redirect from the pages with extension to the ones without.
Thank you
Claudio7810
Member
57 Points
89 Posts
Re: Using an HttpModule to Perform URL Rewriting - Extension-Less URL
Nov 19, 2011 08:19 AM|LINK
The best way to remove the extension is:
<rule name="remove htm extensions"> <!--Removes the .htm extension for all pages.--> <match url="(.*)" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> <add input="{REQUEST_FILENAME}" negate="true" pattern="(.*).htm" /> </conditions> <action type="Rewrite" url="{R:1}.htm" /> </rule>