如何将这些 IIS 重写规则转换为 Nginx 重写规则?

问题描述 投票:0回答:1

如何将这些 IIS 重写规则转换为 nginx 重写规则? 我尝试了一个转换器,但它似乎并没有真正起作用,而且我对 Nginx 也不太熟悉。我用过这个:https://github.com/ismai1/iis-to-nginx

<rule name="Changes URL" stopProcessing="false">
    <match url="^changes/([^/]+)/([^/]+)/?$" />
    <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="changes?year={R:1}&amp;month={R:2}" />
</rule>
<rule name="CMS URL" stopProcessing="false">
    <match url="^content/view/([^/]+)/?$" />
    <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="content/view?id={R:1}" />
</rule>
<rule name="CMS Page URL" stopProcessing="false">
    <match url="^content/view/([^/]+)/([^/]+)/?$" />
    <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="content/view?id={R:1}&amp;cpage={R:2}" />
</rule>
<rule name="CMS Permissions URL" stopProcessing="false">
    <match url="^content/permissions/([^/]+)/?$" />
    <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="content/permissions?id={R:1}" />
</rule>
<rule name="MainPages" stopProcessing="false">
    <match url="^([^/]+)/?$" />
    <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="index.php?page={R:1}" />
</rule>
<rule name="SubPages" stopProcessing="false">
    <match url="^([^/]+)/([^/]+)/?$" />
    <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="index.php?page={R:1}&amp;spage={R:2}" />
</rule>
<rule name="Map Image Redirect 2" stopProcessing="true">
    <match url="^ingame/getmap_image/([^/]+).jpg/?$" />
    <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="ingame/getmap_image.php?map={R:1}" />
</rule>
<rule name="Map Image Redirect" stopProcessing="true">
    <match url="^ingame/getmap_image/large/([^/]+).jpg/?$" />
    <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="ingame/getmap_image.php?map={R:1}&amp;large=1" />
</rule>
xml nginx url-rewriting
1个回答
0
投票

前几天我遇到了这个问题,并在这里找到了一个转换脚本:https://github.com/ismai1/iis-to-nginx/tree/master。我无法让它工作,但你可以。

在 AI 的帮助下,我将此脚本移植到 PHP,并决定制作一个 Laravel 应用程序来完成具有漂亮 UI 的工作。你可以在这里找到它:

Laravel IIS 到 Nginx

享受吧!

© www.soinside.com 2019 - 2024. All rights reserved.