带有 web.config 文件的 IIS 上的 Codeigniter 2 [英] Codeigniter 2 on IIS with web.config file

查看:17
本文介绍了带有 web.config 文件的 IIS 上的 Codeigniter 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 WAMP 在本地运行良好的 codeigniter 应用程序.但是,我无法让它在 IIS 服务器上运行.请注意,我不想启用查询字符串.

I have a codeigniter app working fine locally with WAMP. However, I am having trouble getting it to work on an IIS server. Please note that I do not want to enable query strings.

这是我目前在 web.config 文件中的内容:

Here is what I currently have in my web.config file:

    <?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Clean URL" stopProcessing="true">
                    <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>  

这会导致主页正确加载:www.website.com/policies

This causes the main page to load properly: www.website.com/policies

但是,当我点击一个项目转到:www.website.com/policies/policy/view/31

However, when I click on an item to go to: www.website.com/policies/policy/view/31

未显示正确的页面.主页继续显示.

The proper page is not displayed. The main page continues to be displayed.

控制器是Policy,函数是view().Codeigniter 文件位于服务器上的 policies/文件夹中.

The controller is Policy and the function is view(). The Codeigniter files are in a policies/ folder on the server.

我认为问题可能出在我的 web.config 文件上.配置文件的 $config['base_url'] 是动态计算的,是正确的.配置文件的 $config['index_page'] 为空.您认为是什么导致了这个问题?

I think the problem may be with my web.config file. The Config file's $config['base_url'] is dynamically calculated and is the correct one. The Config file's $config['index_page'] is blank. What do you think is causing this problem?

感谢大家的帮助.

推荐答案

你看过 CI 论坛中的例子吗?

Have you look at the example in the CI forums?

http://codeigniter.com/forums/viewthread/91954

<?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>  

这篇关于带有 web.config 文件的 IIS 上的 Codeigniter 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆