[英]Using ISAPI Rewrite 3 & ASP.Net MVC?
目前,我正在IIS6上使用ISAPI Rewrite3作为两个包含Wordpress的虚拟目录。
我需要在网站的根目录处设置一些规则,以将旧网址重定向到新网址:
i.e.
http://www.example.com/somefolder/* > http://www.example.com/newfolder/
&
http://www.example.com/somefolder/file_1.htm > http://www.example.com/newmvcpath/
我需要做到这一点而不破坏MVC(将其设置为通配符)并且不影响两个虚拟目录。
我还要如何为/ somefolder / file_ 1 .htm数字位设置通配符。
任何帮助,不胜感激
(Heliontech IIs重写)
.htaccess文件
# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.64
RewriteEngine on
#301 Redirections
#FRANCE (all .html files in a folder)
RewriteRule places-in-france/(.*)\.html places/france [NC,R=301]
#Numeric
RewriteRule companies-france/Companies-in-Pyrenees_(.*)\.htm companies/france [NC,R=301]
#rest of stuff
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Add extensions to this rule to avoid them being processed by ASP.NET
RewriteRule (.*)\.(css|gif|png|jpeg|jpg|js|zip) $1.$2 [I,L]
# Prefixes URLs with "rewritten.aspx/", so that ASP.NET handles them
RewriteRule ^(.*) /rewritten.aspx/$1 [I]
向Global.asax.cs添加了代码
protected void Application_BeginRequest(Object sender, EventArgs e)
{
HttpApplication app = sender as HttpApplication;
if (app != null)
if (app.Request.AppRelativeCurrentExecutionFilePath == "~/rewritten.aspx")
app.Context.RewritePath(
app.Request.Url.PathAndQuery.Replace("/rewritten.aspx", "")
);
}
使用此博客中的选项4 http://blog.codeville.net/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/,但稍作修改。
这也意味着我已经关闭了通配符映射。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.