【问题标题】:Grocery crud in windows hostingWindows 主机中的杂货杂货
【发布时间】:2012-06-05 11:12:46
【问题描述】:

我在我的服务器上安装了 Codeigniter,并在上面安装了 Grocery crud。不幸的是,服务器是基于 Windows 的,不支持 url 重写,我被困在使用 Grocery crud 的情况下。

有人可以解释解决方案吗,因为我搜索杂货杂货论坛并没有找到任何东西。

问候

【问题讨论】:

  • 您是在暗示它是基于 Windows 的服务器这一事实可以防止 URL 重写,还是您实际上无权配置此类 URL?
  • 不建议而是寻求解决方案。

标签: php model-view-controller codeigniter-2 grocery-crud


【解决方案1】:

在您的 Web 根目录中创建一个名为 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}" pattern="css|js|jpg|jpeg|png|gif|ico|htm|html" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php/{R:0}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

以上是 Codeigniter 论坛here 上使用的示例。

您可能还需要确保将$config['uri_protocol'] 设置为AUTO

【讨论】:

  • 虽然我从不使用上述配置,但我实现了一个默认解决方案,该解决方案适用于任何托管服务,即更改您的 CI 配置文件并将查询字符串参数更改为 false。现在您可以通过 www.example.com/index.php/ClassName/functionName 访问杂货库库
  • 啊,很公平。您应该接受答案或发布您自己的答案并接受它,这样该问题就不会出现在未回答的列表中。
【解决方案2】:

在 CodeIgniter 中更改配置文件并更改 $config['querystring'] = false

现在您可以像这样访问 GroceryCrud 库函数 www.example.com/index.php/ControllerClass/FunctionName

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多