2

我将我的 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]

有什么建议么?

4

1 回答 1

5

梳理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>
于 2013-03-16T18:45:28.330 回答