如何在Windows Azure上重写Codeigniter的index.php

如何在Windows Azure上重写Codeigniter的index.php,codeigniter,iis,azure,rewrite,Codeigniter,Iis,Azure,Rewrite,如何在Windows Azure和IIS上删除codeigniter中的index.php 我可以在没有特定模块的情况下重写Codeigniter的index.php的URL吗?您可以在web.config文件中添加重写规则。将以下内容添加到system.webServer部分: <rewrite> <rules> <rule name="Rule" stopProcessing="true"> <match url="^(.*)

如何在Windows Azure和IIS上删除codeigniter中的index.php


我可以在没有特定模块的情况下重写Codeigniter的index.php的URL吗?

您可以在web.config文件中添加重写规则。将以下内容添加到
system.webServer
部分:

<rewrite>
  <rules>
    <rule name="Rule" stopProcessing="true">
      <match url="^(.*)$" ignoreCase="false" />
      <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
        <add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
      </conditions>
      <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
    </rule>
  </rules>
</rewrite> 

在wwwroot中创建文件名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="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.php?url={R:1}" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite> 
    </system.webServer>
</configuration>

您还可以实现其他重写规则,如

<rule name="a rule">
<match url="^xxx/(.*)/(.*)-(.*)\.xxx" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="controller/method/{R:3}" />
</rule>


有一个条件,就是更改$config['url\u protocal']='PATH\u INFO';在config/config.php中,这将告诉URL重写模块使用重新写入的URI而不是原始URL,否则您将有404页面未找到问题。

此设置应适用于大多数php框架(zend 1/2、laravel等)这对我不起作用,然后我意识到我将对index.php文件的引用移动到了一个应用程序文件夹中(对于Codeigniter),因此可能需要记住的一点是,这个文件应该位于index.php文件所在的位置。