model view controller - MVC - Make all URLs with a trailing slash 301 to URL without a slash? -


is there way redirect urls end in trailing slash url without?

in application_beginrequest method in global.asax, add following:

if (httpcontext.current.request.url.absolutepath != "/" && httpcontext.current.request.url.absolutepath.endswith("/")) {     string redirect = httpcontext.current.request.url.absolutepath;     redirect = redirect.remove(redirect.length - 1);     response.clear();     response.status = "301 moved permanently";     response.addheader("location", redirect);     response.end(); } 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -