How to rewrite the index.php of Codeigniter on Windows Azure

前端 未结 3 2040
日久生厌
日久生厌 2020-11-28 10:31

How to remove index.php in codeigniter on Windows Azure and IIS?

Can I rewrite the URL for the index.php of Codeigniter without a particular module?

相关标签:
3条回答
  • 2020-11-28 11:15

    You can add rewrite rules in your web.config file. Add the following to the system.webServer section:

    <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> 
    
    0 讨论(0)
  • 2020-11-28 11:15

    Create a file name web.config in wwwroot

    <?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>
    
    0 讨论(0)
  • 2020-11-28 11:19

    You can also implement other rewrite rules like

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

    with one condition, is to change $config['url_protocal']='PATH_INFO'; in config/config.php this will tell URL rewrite module to use re-writed URI instead of original URL, otherwise you will have 404 page not found problem.

    0 讨论(0)
提交回复
热议问题