iis上的web.config静态规则怎么转成可以在Nginx上用的?

下面是iis下的web.config文件:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>

        <security>
          <requestFiltering>
            <requestLimits maxAllowedContentLength="2147483647"></requestLimits>
          </requestFiltering>
        </security>
        <rewrite>
            <rules>
                <rule name="已导入的规则 1" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
                </rule>
                <rule name="http redirect to https" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTPS}" pattern="^OFF$" />
                        <add input="{HTTPS_HOST}" pattern="^(localhost)" negate="true" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
                </rule>
            </rules>
        </rewrite>
        <httpErrors errorMode="DetailedLocalOnly" />
        <httpProtocol>
            <customHeaders>
                <add name="X-Frame-Options" value="SAMEORIGIN" />
                <remove name="X-Powered-By" />
            </customHeaders>
        </httpProtocol>
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
                <add value="index.html" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="iisstart.htm" />
                <add value="default.aspx" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>

这规则怎么在Nginx上用?

阅读 2.4k
1 个回答

看了一下大概是 如下意思

server {
    listen 80; #监听http 80 端口 如果是http 访问,直接 301跳转到 https
    server_name domain-name.com www.domain-name.com;
    return 301 https://domain-name.com$request_uri;  
}
server {
    listen 443 
    server_name www.domain-name.com;
    # https 相关内容自己配
    #把所有请求转发到index.php上 具体你自己再调试一下,大概就是这个样子
    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题