【问题标题】:CakePHP on IIS7 - no css/js/imgIIS7 上的 CakePHP - 没有 css/js/img
【发布时间】:2012-02-04 09:47:22
【问题描述】:

我无法加载 css、js 和 img。 我一直在使用本文中的 web.config: http://book.cakephp.org/view/1533/A-Note-on-mod_rewrite请给点建议……

【问题讨论】:

  • 我建议使用 Apache,但如果您被 IIS 卡住,请尝试查看日志,因为浏览器请求 css/js/img,您应该通过查看 IIS 日志获得线索。
  • 你能最终解决它吗,Kim?
  • 不,我们无法解决。我们已经切换到 apache。

标签: cakephp iis-7 url-rewriting web-config


【解决方案1】:

插入这条规则

<rule name="Imported Rule 0" stopProcessing="true">
    <match url="^(img|css|files|js)(.*)$" />
    <action type="Rewrite" url="/app/webroot/{R:1}{R:2}" appendQueryString="false" />
</rule>

与 cakephp.org 的网站规则一起:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Imported Rule 0" stopProcessing="true">
                    <match url="^(img|css|files|js)(.*)$" />
                    <action type="Rewrite" url="/app/webroot/{R:1}{R:2}" appendQueryString="false" />
                </rule>
                <rule name="Imported Rule 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?url={R:1}" appendQueryString="true" />
                </rule>
                <rule name="Imported Rule 3" stopProcessing="true">
                    <match url="^$" ignoreCase="false" />
                    <action type="Rewrite" url="/app/webroot/" />
                </rule>
                <rule name="Imported Rule 2" stopProcessing="true">
                    <match url="(.*)" ignoreCase="false" />
                    <action type="Rewrite" url="/app/webroot/{R:1}" />
                </rule>           
                <rule name="Imported Rule 1-1" stopProcessing="true">
                    <match url="^$" ignoreCase="false" />
                    <action type="Rewrite" url="/" />
                </rule>
                <rule name="Imported Rule 2-1" stopProcessing="true">
                    <match url="(.*)" ignoreCase="false" />
                    <action type="Rewrite" url="/{R:1}" />
                </rule>                  
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

【讨论】:

  • 我已经完成了,但它似乎不起作用......它仍在尝试加载 ISS 徽标图像。
【解决方案2】:

我遇到了同样的问题,经过几个小时的研究,这就是我解决问题的方法: 我已在 CakePHP 文件夹上将权限设置为所有人的完全控制。之后我不再需要任何 .htaccess 文件或 web.config

【讨论】:

  • 您使用的是 IIS7 吗?我已经完成了,但我没有得到结果...当我添加 web.config 时,它只是试图显示 ISS 徽标,当不这样做时,它向我显示“URL 重写未正确配置在您的服务器”
猜你喜欢
  • 1970-01-01
  • 2012-09-11
  • 2013-07-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-05
相关资源
最近更新 更多