문제

WordPress가 포함 된 두 개의 가상 디렉토리에 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를 깨지 않고 (와일드 카드로 설정) 두 가지 가상 디렉토리에 영향을 미치지 않으면 서이 작업을 수행해야합니다.

또한 /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-spnet-mvc-to-6/ 그러나 약간 수정되었습니다.

이것은 또한 내가 와일드 카드 매핑을 끄는 것을 의미합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top