In a hosted IIS7 environment, I am looking for the simplest way to use extension-less file names. Simply I have the following pages:
index.html (or .aspx) --> domain.com gallery.html --> domain.com/gallery videos.html --> domain.com/videos etc...
I only have a handful of pages, I have no dynamic code, nothing special. All the examples I have found or methods I use in other sites I've developed revolve around dynamic content, pages, etc. I am simply looking for the simplest solution, ideally not requiring any sort of url rewrite module installed. Preferably, I could keep the .html extension instead of converting the site to a ASP.NET project, but that is an option.
Thanks.
The . html extension can be easily removed by editing the . htaccess file.
Active Server Pages (ASPX) is a file format used by web servers and generated using the Microsoft ASP.NET framework - an open-source development framework used by web developers to create dynamic web pages, often with the . NET and C# programming languages.
aspx is like an HTML page.
Default. aspx - The default webpage loaded when a client browser requests a web server directory on a Microsoft IIS-based server that uses ASP.NET.
I ended up using the following sites:
http://blogs.msdn.com/b/carlosag/archive/2008/09/02/iis7urlrewriteseo.aspx
and
http://forums.iis.net/t/1162450.aspx
or basically the following code in my web.config file using the IIS7 URL Rewrite Module that most hosted sites now offer (in this case I am using GoDaddy):
<system.webServer> <rewrite> <rules> <rule name="RewriteASPX"> <match url="(.*)" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="{R:1}.aspx" /> </rule> </rules> </rewrite> </system.webServer>
Another little bit more modern way to do this is using Microsoft.AspNet.FriendlyUrls. In the Global.asax.cs add:
void Application_Start(object sender, EventArgs e) { // Code that runs on application startup RouteConfig.RegisterRoutes(RouteTable.Routes);
and in the RouteConfig file
public static class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { var settings = new FriendlyUrlSettings(); settings.AutoRedirectMode = RedirectMode.Permanent; routes.EnableFriendlyUrls(settings); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With