Mit ISAPI Rewrite 3 & ASP.Net MVC?
-
05-07-2019 - |
Frage
Ich bin mit ISAPI Rewrite3 auf IIS6 für zwei virtuelle Verzeichnisse im Moment, dass Wordpress enthalten.
Ich brauche einige Regeln an der Wurzel der Site-Setup alten URLs auf neue URLs zu umleiten:
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/
Ich muss dies tun, ohne MVC zu brechen (wie der Satz Wildcard) und ohne die beiden virtuellen Verzeichnisse zu beeinflussen.
Auch, wie würde ich eine Wildcard für bis /somefolder/file_1.htm des numerischen Bit.
Jede Hilfe sehr geschätzt
(heliontech iis Rewrite)
Lösung
.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 hinzugefügt, um 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", "")
);
}
Mit der Option 4 aus diesem Blog http://blog.codeville.net/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/ aber etwas geändert.
Dies bedeutet auch, ich Wildcard-Mapping ausgeschaltet haben.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow