1

经过大量测试,我坚持将 web.config 转换为 .htaccess

我发现存在重定向循环问题。

这是 web.config 代码

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <clear />
                <rule name="Rewrite Client URL" enabled="true" stopProcessing="true">
                    <match url="^([a-zA-Z0-9\-+]+)(\/([a-zA-Z0-9\-\.]+)?)?$" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{R:1}" negate="true" pattern="manage" />
                        <add input="{R:3}" negate="true" pattern="^$" />
                    </conditions>
                    <action type="Rewrite" url="{R:3}?client={R:1}" appendQueryString="true" />
                </rule>
                <rule name="When no files are specified">
                    <match url="^([a-zA-Z0-9\-+]+)(\/([a-zA-Z0-9\-\.]+)?)?$" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{R:1}" negate="true" pattern="manage" />
                        <add input="{R:3}" pattern="^$" />
                    </conditions>
                    <action type="Rewrite" url="index.php?client={R:1}" />
                </rule>
            </rules>
        </rewrite>
        <defaultDocument>
            <files>
                <add value="index_flash.php" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>

这是我的 .htaccess 代码

RewriteEngine On
RewriteRule ^([a-zA-Z0-9\-+]+)(\/([a-zA-Z0-9\-\.]+)?)?$ $1?client=$2
RewriteRule ^([a-zA-Z0-9\-+]+)(\/([a-zA-Z0-9\-\.]+)?)?$ index.php?client=$1
4

0 回答 0