簡體   English   中英

使用ISAPI Rewrite 3和ASP.Net MVC?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM