vb.net - How to re-write url in asp.net 3.5 -


i converted project html aspx

issue is, extension got changed.

e.g. "www.example.com\index.html" changed "www.example.com\index.aspx"

which give problem seo's.

so when search web link www.example.com\index.html , if try go in it, give me error of 404 file not found.

i tried couple of methods url-rewriting, works fine @ local side, fails @ server side.

both tried in global.asax

1.

protected overloads sub application_beginrequest(byval sender object, byval e system.eventargs)          dim currentpath string = request.path.tolower()         dim strpagename string = currentpath.substring(currentpath.lastindexof("/") + 1, (currentpath.lastindexof(".") - currentpath.lastindexof("/")) + 4)          if strpagename.endswith(".html")             select case strpagename                 case "index.html"                     rewriteurl(currentpath)             end select         end if end sub  protected sub rewriteurl(byval url string)     dim currentpath string = url     currentpath = currentpath.replace(".html", ".aspx")     dim mycontext httpcontext = httpcontext.current     mycontext.rewritepath(currentpath) end sub 

2.

sub application_start(byval sender object, byval e eventargs)     registerroutes(routetable.routes) end sub  shared sub registerroutes(byval routes routecollection)     routes.add("index", new route _     ( _        "index.html", new customroutehandler("~/index.aspx") _     )) end sub 

do have control of web server? need seo-wise create permanent (301) url redirect can @ web server level...often in server settings, or in script file.

see: http://en.wikipedia.org/wiki/url_redirection

i realize doesn't answer question directly, if trying search results correct new page, best way it.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -