Codeigniter 2在IIS上使用web.config文件 [英] Codeigniter 2 on IIS with web.config file

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

问题描述

我有一个codeigniter应用程序在本地工作与WAMP。但是,我无法使其在IIS服务器上工作。请注意,我不想启用查询字符串。



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

 <?xml version =1.0encoding =UTF-8?> 
< configuration>
< system.webServer>
< rewrite>
< rules>
< rule name =Clean URLstopProcessing =true>
< match url =^(。*)$/>
< conditions>
< add input ={REQUEST_FILENAME}matchType =IsFilenegate =true/>
< add input ={REQUEST_FILENAME}matchType =IsDirectorynegate =true/>
< / conditions>
< action type =Rewriteurl =index.php / {R:1}appendQueryString =false/>
< / rule>
< / rules>
< / rewrite>
< /system.webServer>
< / configuration>

这将导致主页正常加载:www.website.com/policies



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



不显示正确的页面。



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



我认为问题可能出在我的web.config文件中。配置文件的$ config ['base_url']是动态计算,是正确的。配置文件的$ config ['index_page']为空。

解决方案

/ div>

您看看CI论坛中的示例吗?



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

 <?xml version = 1.0encoding =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 | htmlnegate =true/>
< / conditions>
< action type =Rewriteurl =index.php / {R:0}/>
< / rule>
< / rules>
< / rewrite>
< /system.webServer>
< / configuration>


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.

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>  

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

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.

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

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?

Thank you all for your help.

解决方案

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>  

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

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