繁体   English   中英

从 url codeigniter 中删除 index.php 文件在 Windows 服务器中不起作用

[英]Remove index.php file from url codeigniter didn't work in Windows server

How to remove index.php from windows server 从这里找到答案

尝试了以下方法。

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>

但它对我不起作用。

您可以尝试以下步骤:

打开文件夹“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。

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

 Options +FollowSymLinks
 RewriteEngine On

 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^ index.php [L]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM