<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <!-- Laravel URL 重写 -->
                <rule name="Laravel to index.php" stopProcessing="true">
                    <match url="^(.*)$" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>

        <!-- 禁止访问隐藏文件 -->
        <security>
            <requestFiltering>
                <hiddenSegments applyToWebDAV="false">
                    <add segment=".env" />
                    <add segment=".git" />
                    <add segment=".svn" />
                </hiddenSegments>
            </requestFiltering>
        </security>

        <!-- 上传目录禁止执行 PHP -->
        <location path="Uploads">
            <system.webServer>
                <handlers>
                    <remove name="PHP_via_FastCGI" />
                    <remove name="PHP7_via_FastCGI" />
                    <remove name="PHP8_via_FastCGI" />
                </handlers>
            </system.webServer>
        </location>

        <!-- 静态资源缓存（30 天） -->
        <staticContent>
            <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" cacheControlCustom="public, immutable" />
        </staticContent>
    </system.webServer>
</configuration>
