سؤال

وأنا باستخدام ISAPI Rewrite3 على IIS6 لمدة الدلائل الظاهرية في اللحظة التي تحتوي على وورد.

ولست بحاجة إلى إعداد بعض القواعد في جذر الموقع لإعادة توجيه عناوين المواقع القديمة إلى عناوين جديدة:

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 كتابة)

هل كانت مفيدة؟

المحلول

وملف هتكس

# 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 من هذا بلوق <لأ href = "http://blog.codeville.net/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/" يختلط = " نوفولو noreferrer "> http://blog.codeville.net/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/ لكن قليلا المعدلة.

وهذا يعني أيضا لقد تحولت رسم الخرائط البدل خارج.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top