0

現在、Wordpress を含む 2 つの仮想ディレクトリに対して IIS6 で ISAPI Rewrite3 を使用しています。

古い URL を新しい URL にリダイレクトするには、サイトのルートにいくつかのルールを設定する必要があります。

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 を壊さずに (ワイルドカードに設定されているため)、2 つの仮想ディレクトリに影響を与えずにこれを行う必要があります。

また、 /somefolder/file_ 1 .htm 数値ビットにワイルドカードを設定するにはどうすればよいですか。

どんな助けでも大歓迎です

(heliontech iis リライト)

4

1 に答える 1

0

.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", "")
            );
}

このブログhttp://blog.codeville.net/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/のオプション4を使用しています が、わずかに修正されています。

これは、ワイルドカードマッピングをオフにしたことも意味します。

于 2009-11-27T14:26:13.463 に答える