Подтвердить что ты не робот

Как переписать index.php Codeigniter в Windows Azure

Как удалить index.php в codeigniter в Windows Azure и IIS?

Можно ли переписать URL-адрес для index.php Codeigniter без определенного модуля?

4b9b3361

Ответ 1

Вы можете добавить правила перезаписи в свой файл 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> 

Ответ 2

Создайте имя файла web.config в 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>

Ответ 3

Вы также можете реализовать другие правила перезаписи, например

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

с одним условием - изменить $config ['url_protocal'] = 'PATH_INFO'; в config/config.php это будет указывать модуль перезаписи URL-адресов для использования повторно отозванного URI вместо исходного URL-адреса, иначе у вас будет проблема с 404 страницами.