ASP.Net MVC - 捕获特定的URL做301重定向
我从一个旧的网站设计移动到一个新的设计,新的URL。
I am moving from an old site design to a new design with new URL's.
所有previous页的名字是静态文件名为PageXX.html,PageX.html,的Index.html - 其中X是一个数字
All previous page names were static files called PageXX.html, PageX.html, Index.html - where X is a number.
我的网站现在是动态的,但我想陷阱对于那些3传入的URL,然后尝试并重定向到某个新的一页(301重定向)别人送他们到首页。
My site is now dynamic but I want to trap for those 3 incoming url's and then try and redirect to a certain new page (301 Redirect) else send them to the home page.
我做这一切在Global.asax中或做我只是陷阱的网址在Global.asax中,然后将其路由到一个动作,做301重定向的动作?
Do I do all of this in Global.asax or do I just trap those Url's in Global.asax and then route it to a Action and do a 301 Redirect in the Action?
任何code例子将有很大的帮助!
Any code examples would help a lot!
感谢
编辑:我觉得需要做的是陷阱在Global.asax中的路由,然后将它们发送到行动,将工作从哪里发送用户即什么。在新网站上的类似页面一样,我将发送到首页。
I think what needs to be done is trap the routes in Global.asax and then send them to a Action which will work out where to send the user ie. a similar page on the new site else I will send to the home page.
这是正确的,只是做在你的路由配置(通常在Global.asax中)。您可以设置这些静态特殊情况。
That's right, just do it in your routes configuration (usually in global.asax). You can set these up as static special cases.
routes.MapRoute("Page3",
"SomeURL/Page3.html",
new {
controller = "SomeController",
action = "SomeAction",
page = "2"
});