- Offizieller Beitrag
So scheint als hätte ich endlich kapiert wie es funktioniert - man sollte halt doch mal doku lesen.
Wicht bzgl. IIS rewqrite ist erstmal folgendes:
ZitatAccessing URL Parts from a Rewrite Rule
It is important to understand how certain parts of the URL string can be accessed from a rewrite rule.
For an HTTP URL in this form: http(s)://<host>:<port>/<path>?<querystring>
- The <path> is matched against the pattern of the rule.
- The <querystring> is available in the server variable called QUERY_STRING and can be accessed by using a condition within a rule.
- The <host> is available in the server variable HTTP_HOST and can be accessed by using a condition within a rule.
- The <port> is available in the server variable SERVER_PORT and can be accessed by using a condition within a rule.
- Server variables SERVER_PORT_SECURE and HTTPS can be used to determine if a secure connection was used. These server variables can be accessed by using a condition within a rule.
- The server variable REQUEST_URI can be used to access the entire requested URL path, including the query string.
For example, if a request was made for this URL:
http://www.mysite.com/content/default.aspx?tabid=2&subtabid=3
, and a rewrite rule was defined on the site level then:
- The rule pattern gets the URL string
content/default.aspx
as an input.- The QUERY_STRING server variable contains
tabid=2&subtabid=3
.- The HTTP_HOST server variable contains
www.mysite.com
.- The SERVER_PORT server variable contains
80
.- The SERVER_PORT_SECURE server variable contains
0
and HTTPS containsOFF
.- The REQUEST_URI server variable contains
/content/default.aspx?tabid=2&subtabid=3
.- The PATH_INFO server variable contains
/content/default.aspx
.Note that the input URL string passed to a distributed rule is always relative to the location of the Web.config file where the rule is defined. For example, if a request is made for
http://www.mysite.com/content/default.aspx?tabid=2&subtabid=3
, and a rewrite rule is defined in the /content directory, then the rule gets this URL string default.aspx as an input.
zu finden unter https://docs.microsoft.com/en-us/iis/exte…ation-reference
Damit man erstmal weiss was man da überhaupt vergleicht. Dann muss man sich noch bzgl. regular experessions vertrauter machen und schon klappt es
<rule name="wbb wcf rewrite">
<match url="^wbb/wcf/(.*)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}" />
</rule>
<rule name="wbb rewrite">
<match url="^wbb/(.*)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}" />
</rule>
<rule name="forum missing rewrite" enabled="true">
<match url="^index.php(.*)$" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
<add input="{QUERY_STRING}" pattern="^thread/.*" />
</conditions>
<action type="Rewrite" url="forum/index.php?{QUERY_STRING}" appendQueryString="false" logRewrittenUrl="true" />
</rule>
<rule name="http to https redirect" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
<add input="{HTTPS}" pattern="OFF" />
</conditions>
<action type="Redirect" url="https://www.elektrifiziert.net/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
Alles anzeigen
oben mal meine aktuellen rules die ersten beiden dienen dazu aus den alten URLs (alte domain) wbb und wbb/wcf herauszuschneiden. Die dritte um ein fehlendes forum einzusetzen und die letzte sorgt dafür dass nur https genutzt wird.
Anmerkung:
Alte URLs die schon auf https umgestellt waren ala "https://okedv.dyndns.org/...) sind leider nicht automaitsch umsetzbar, da zuerst das Zertifikat geprüft wird - was dann aber fehlschlägt.