Skip to content

Instantly share code, notes, and snippets.

@hgirish
Last active November 3, 2016 05:26
Show Gist options
  • Save hgirish/9ff5c6143f36a8659621 to your computer and use it in GitHub Desktop.
Save hgirish/9ff5c6143f36a8659621 to your computer and use it in GitHub Desktop.
RouteConfig for ignoring bot requests
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*vti_inf}", new { vti_inf = @"(.*/)?_vti_inf.html(/.*)?" });
routes.IgnoreRoute("{*vti_rpc}", new { vti_rpc = @"(.*/)?_vti_rpc(/.*)?" });
routes.IgnoreRoute("{*allphp}", new { allphp = @".*\.php(/.*)?" });
routes.IgnoreRoute("{*allcgi}", new { allcgi = @".*\.cgi(/.*)?" });
routes.IgnoreRoute("{*allaspx}", new { allaspx = @".*\.aspx(/.*)?" });
routes.IgnoreRoute("{*favicons}", new { favicons = @".*favicon\.(ico|gif|png)(/.*)?" });
routes.IgnoreRoute("{*allappleicon}", new { allappleicon = @"apple-touch-icon.*\.png(/.*)?" });
routes.IgnoreRoute("ckfinder/{*pathInfo}");
routes.IgnoreRoute("{*allsql}", new { allsql = @".*\.sql(/.*)?" });
routes.IgnoreRoute("{*allwpinclude}", new { allwpinclude = @"wp-includes.*(/.*)?" });
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment