php - 在 IIS 上部署 PHP 应用程序

标签 php codeigniter iis web-config

我正在尝试在 IIS 服务器上部署我的 CODEIGNITER 应用程序。我的测试脚本 hello word 在 IIS 上运行,但是当我移动我的 CI 应用程序并检查错误日志时,任何 url 都显示 404。我尝试添加 web.config 文件以重写 root 上的规则,这里仍然发生错误是 web.config 文件

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
  <rewrite>
          <rules>
              <rule name="Index">
              <match url="^(.*)$" />
              <conditions>
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
              </conditions>
                    <action type="Rewrite" url="index.php/{R:1}" />
            </rule>
          </rules>
        </rewrite>
    </system.webServer>
</configuration>

最佳答案

试试这个 web.config

<?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="Rewrite to index.php">
                        <match url="index.php|robots.txt|images|test.php" />
                        <action type="None" />
                    </rule>
                    <rule name="Rewrite CI Index">
                        <match url="^(.*)$" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.php/{R:1}" appendQueryString="false" /> </rule>
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>

在 config.php 文件中,将 $config['uri_protocol']= 'QUERY_STRING' 更改为 $config['uri_protocol'] = 'AUTO'

关于php - 在 IIS 上部署 PHP 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36855124/

相关文章:

asp.net - 是什么限制了我的 ASP.NET 应用程序可以与 Web 服务建立的同时连接数?

sql-server - 在 Server 2008 R2 上禁用旧 SSL 时站点加载和 sql 连接出现问题

php - 创建采用数组的 SQL 查询

php - 如何使用 jQuery 条件测试设置 php 变量?

php - 如何在php中查看其他用户的个人资料?

php - CodeIgniter 对没有主键的表进行查询

codeigniter - CodeIgniter 中的查询结果

php - 使用 Silex 的 Twig addFilter?

php - Codeigniter 缓存文件不会被删除

iis - 如何创建文件 applicationhost.config