好的!
最近我用 CI 和杂货杂货做了一个管理控制面板。它在我的本地服务器上与 WAMP 配合得很好,具有漂亮的 URL 和重定向。我在谈论 CI 是我工作过的最好的框架。它非常易于使用,并且有很好的文档记录 干杯!到 CodeIgniter。
但是当我不得不在 IIS 服务器 7.XX 上移动我的管理面板时,我的噩梦似乎开始了。一切都停止了没有重定向,没有错误显示什么都没有发生。我很害怕为什么会这样。我在谷歌、堆栈溢出、CI 论坛上挖了将近 6 个小时。我没有从任何地方收到任何东西。我很伤心:(
我想不出我应该做什么。然后,我让自己冷静下来,开始一步一步地回顾这里的一切:
1. Set error reporting on
2. Check PHP info
3. Check redirect/rewrite
4. Check MySQL/MySQLi extension loaded or not in IIS server
5. Converted my .htaccess file rule with web.config rule (Really helped me)
6. Put web.config file in the main directory (CI working folder) not in the root folder
如何在 web.config 中转换 .htaccess?
然后,我发现一切都是正确的,除了 IIS 服务器上没有加载“mysqli”扩展名并且我的数据库配置凭据错误。然后我在 php.ini 中进行了更改(检查'phpinfo()'以在 IIS 服务器上找到 php.ini 路径)第 881 行,取消注释扩展 = php_mysqli.dll。
这是我的 CI 配置设置:
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
之后,现在重新打开我的 CI 管理面板!!!!!!一切哇!哇!!像魅力一样工作:) 嘿嘿嘿…… 我非常开心 :) :)
这是我的 web.config 文件
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1">
<match url="(.*)" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTPS}" pattern="off" ignoreCase="false" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{URL}" redirectType="Found" />
</rule>
<rule name="Imported Rule 1-1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{URL}" pattern="^system.*" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="index.php?/{R:1}" appendQueryString="false" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{URL}" pattern="^application.*" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="/index.php?/{R:1}" appendQueryString="false" />
</rule>
<rule name="Imported Rule 3" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php?/{R:1}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
这是我漂亮的 URL 类型
https://mysite.abc.com/administrator/admin/showUsers
the administrator is my admin folder
admin is my controller
and showUsers in my controller method
希望我的糟糕经历会对某人有所帮助:)