ste*_*nix 8 php iis codeigniter web-config codeigniter-2
我有一个codeigniter应用程序在WAMP本地工作正常.但是,我无法让它在IIS服务器上工作.请注意,我不想启用查询字符串.
这是我目前在web.config文件中的内容:
<?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>
Run Code Online (Sandbox Code Playgroud)
这会导致主页面正确加载:www.website.com/policies
但是,当我点击某个项目时,请访问:www.website.com/policies/policy/view/31
不显示正确的页面.主页面继续显示.
控制器是Policy,函数是view().Codeigniter文件位于服务器上的策略/文件夹中.
我认为问题可能出在我的web.config文件中.Config文件的$ config ['base_url']是动态计算的,是正确的.Config文件的$ config ['index_page']为空白.您认为导致此问题的是什么?
感谢大家的帮助.
Jak*_*kub 32
您是否看过CI论坛中的示例?
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>
Run Code Online (Sandbox Code Playgroud)
小智 5
我已将以下 web.config 代码放置在根目录中,并且运行良好。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 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}" />
</rule>
<rule name="Imported Rule 2" 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" />
<add input="{R:1}" pattern="^(index\.php|images|robots\.txt|css)" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php?{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)