2017-09-19 9 views
-1

Ich habe eine Rewrite-Regel in meinem MVC-Projekt-URL einer HTTP-Anforderung an HTTPS neu zu schreiben:Redirect von HTTP auf HTTPS und auf eine neue Domain mit C# MVC in IIS7.5

<rewrite> 
    <rules> 
    <rule name="Redirect HTTP to HTTPS" enabled="true" patternSyntax="Wildcard" stopProcessing="true"> 
     <match url="*" /> 
     <conditions logicalGrouping="MatchAny"> 
     <add input="{HTTPS}" pattern="off" /> 
     </conditions> 
     <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Found" /> 
    </rule> 
    </rules> 
</rewrite> 

Aber jetzt brauche ich Um alle Anfragen von der ursprünglichen www.company.com auf eine neue URL www2.company.com umleiten

Wie kann ich das tun, um auch das ursprüngliche HTTP zu HTTPS zu behalten?

Änderungen an Google Analytics für diese neue Weiterleitung?

EDIT:

Beispiele:

http://old.company.com -> https://new.company.com 
https://old.company.com -> https://new.company.com 
http://www.old.company.com -> https://new.company.com 
https://www.old.company-com -> https://new.company.com 
http://old.company.com/Account/Login -> https://new.company.com/Account/Login 
https://old.company.com/Account/Login -> https://new.company.com/Account/Login 
+1

Eine Umleitung und eine URL-Umschreibung sind * komplett * verschiedene Dinge. – Amy

+0

Hallo, mein Verständnis davon ist, dass die Rewrite-Regeln mir helfen, die Anfrage umzuleiten, bin ich richtig? – Patrick

+1

Nein, Neuschreibungen haben buchstäblich nichts mit Umleitungen zu tun. Du bist nicht korrekt. – Amy

Antwort

-1

können Sie Rewrite-Regeln verwenden, um mehrere Domänen zu behandeln. Hier ist ein Beispiel, das Regex Matching auf url enthält:

<rewrite> 
    <globalRules> 
     <rule name="Redirects to HTTPS and www.example.com" patternSyntax="ECMAScript" stopProcessing="true"> 
      <match url=".*" /> 
      <conditions logicalGrouping="MatchAny"> 
       <add input="{HTTP_HOST}" pattern="^example.*(com|net)$" /> 
       <add input="{HTTP_HOST}" pattern="^(www.)?example2.(com|net)$" /> 
       <add input="{HTTP_HOST}" pattern="^www.example.net$" /> 
      </conditions> 
      <action type="Redirect" url="https://www.example.com/{R:0}" /> 
     </rule> 
    </globalRules> 
</rewrite> 

Siehe this article für weitere Informationen, wie zu erreichen, was Sie brauchen.

+0

Ich sehe nicht, wo Ihre Antwort HTTPS überhaupt verwendet. Ich denke, du musst die Frage noch einmal lesen. – Amy

+0

Hallo @SlimGhost, ich verstehe nicht, Ihre Antwort auf mein Problem angewendet, können Sie mir dabei helfen? – Patrick

+0

@Patrick sorry, ich habe das "S" in HTTPS weggelassen. Wird das nicht das tun, was Sie wollen (http://example1.com und http://example2.com zu https://example1.com umleiten)? – SlimsGhost

Verwandte Themen