gpt4 book ai didi

iis-7 - Zend Framework 2 IIS url 重写

转载 作者:行者123 更新时间:2023-12-02 22:10:05 24 4
gpt4 key购买 nike

我将我的 zend 项目从 Apache 转移到 IIS 7 并设置了 URL Rewrite。主页显示正常,但未加载 css 和 javascript。

这是我重写的脚本

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="index.php" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^.*$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="public/index.php" />
</rule>
<rule name="Imported Rule 1-1" stopProcessing="true">
<match url="\.(js|ico|txt|gif|jpg|png|css)$" ignoreCase="false" negate="true" />
<action type="Rewrite" url="public/index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

这是原始的 mod_rewrite 规则

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

有什么建议吗?

最佳答案

通过Zend2的文档梳理后,我找到了这个例子。完美运行!我希望这可以帮助其他人。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^.*$" />
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_FILENAME}"
matchType="IsFile" pattern=""
ignoreCase="false" />
<add input="{REQUEST_FILENAME}"
matchType="IsDirectory"
pattern="" ignoreCase="false" />
</conditions>
<action type="None" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^.*$" />
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

关于iis-7 - Zend Framework 2 IIS url 重写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15451455/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com