【问题标题】:Remove index.php file from url codeigniter didn't work in Windows server从 url codeigniter 中删除 index.php 文件在 Windows 服务器中不起作用
【发布时间】:2016-05-09 11:40:44
【问题描述】:

如何从 Windows 服务器中删除 index.php 从this 找到答案

尝试了以下方法。

1.在我的codeigniter项目的根目录中创建一个名为web.config的文件。

2.将以下内容放在它上面

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <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>
</system.webServer>
</configuration>

但它对我不起作用。

【问题讨论】:

    标签: php .htaccess codeigniter azure


    【解决方案1】:

    从 url 中删除 index.php 是必须使用 htaccess 完成的, 转到应用程序的根目录并创建一个名为“.htaccess”的新文件并输入以下内容:

     Options +FollowSymLinks
     RewriteEngine On
    
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteRule ^ index.php [L]
    

    【讨论】:

      【解决方案2】:

      您可以尝试以下步骤:

      打开文件夹“application/config”并打开文件“config.php”。在 config.php 文件中查找并替换以下代码。

      //find the below code   
      $config['index_page'] = "index.php" 
      //replace with the below code
      $config['index_page'] = ""
      

      然后找到如果你有代码$config['uri_protocol'] = "AUTO"更改为$config['uri_protocol'] = "REQUEST_URI"

      web.config的内容应该没问题,修改文件时需要重启Azure Web Apps Server。

      【讨论】:

        猜你喜欢
        • 2020-02-10
        • 2018-07-12
        • 2015-04-23
        • 2015-12-29
        • 2013-10-04
        • 2015-06-24
        • 1970-01-01
        • 2016-05-14
        • 2014-10-28
        相关资源
        最近更新 更多