Hiding default.aspx from url

I wanted to know if there is a solution using IIS6 for the application to get rid of the default.aspx text in the url. so, for example, if the user clicks:

www.website.com/default.aspx

The browser only shows:

www.website.com/

Never mind. It is easy for SEO.

I already use UrlRewriting.NET for some rewrites in my application, but I'm not smart enough to create a rule for this.

Any help is greatly appreciated.

Thanks. Jose

+3
source share
5 answers

If you have something you need to do to rewrite the URLs, then all you have to do is make sure your links point to the correct URL.

, , , .

, javascript, , , .

+1

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

, :

  • UrlRewriter.net, ISAPI
  • ASP.NET, ( URL-)

, , , "default.aspx", .. '/'. Scott Form Postback, , URL-.

'default.aspx' '/', .aspx, . , , "default.aspx".

+3

, ( , HTTP 301) - default_aspx Page_Load, , 301 Moved Permently ( 302 Moved Temporarily).

void Page_Load(...) {

    if(Request.Path.EndsWith("default.aspx", true/*case-insensitive*/, null)) {
       Response.StatusCode = 301;
       Response.StatusDescription = "Moved Permanently";
       Response.Headers.Add("Location", "/");
       HttpContext.Current.ApplicationInstance.CompleteRequest(); // end the request
    }

    // do normal stuff here
}
+2

default.aspx IIS, URL- default.aspx, , .

default.aspx, URL- href .

+1

, Application_BeginRequest Global: System.Web.HttpApplication HttpContext.Current.Request.URL .aspx, HttpContext.Current.Response.Redirect .

The disadvantage of redirection is not always so great, and it will not work if you send data to this default.aspx page. But you cannot just fool the browser by providing a different URL, although you can say that ASP.NET serves any page you want for any request.

0
source

Source: https://habr.com/ru/post/1710737/


All Articles