Question

J'utilise actuellement ISAPI Rewrite3 sur IIS6 pour deux répertoires virtuels contenant Wordpress.

Je dois configurer des règles à la racine du site pour rediriger les anciennes URL vers de nouvelles:

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/

Je dois le faire sans casser MVC (défini comme un caractère générique) et sans affecter les deux répertoires virtuels.

Comment puis-je définir un caractère générique pour /somefolder/file_1.htm le bit numérique.

Toute aide grandement appréciée

(réécriture hélisale iis)

Était-ce utile?

La solution

fichier .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]

Code ajouté à 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", "")
            );
}

Utilisation de l'option 4 de ce blog http://blog.codeville.net/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/ mais légèrement modifié.

Cela signifie également que j'ai désactivé le mappage générique.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top