【问题标题】:I am unable to remove index.php from URl in codeigniter 3.1.11我无法从 codeigniter 3.1.11 中的 URl 中删除 index.php
【发布时间】:2020-02-13 11:06:47
【问题描述】:

我尝试从可用的文档中将 .htaccess 添加到根文件夹中。我搜索了整个互联网,但没有解决我的问题。

.htaccess 中的代码

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

修改了apache文件httpd

LoadModule rewrite_module modules/mod_rewrite.so

谁能告诉我可能是什么原因?

【问题讨论】:

  • 可能是权限问题。需要先检查权限。
  • 您能列出到目前为止您尝试过的内容吗?我对这个话题一无所知,但如果你消除已经尝试过的方法,那些知道的人可以给你一个更快的答案。
  • 目前还不清楚,你想在这里实现什么。你想从文件系统中删除 index.php 吗?那么这与重写规则和给定的配置文件无关。如果您想保护 index.php 免受外部访问,请在您的问题中说明这一点。

标签: php .htaccess codeigniter


【解决方案1】:
Find the below code
 $config['index_page'] = "index.php"
Remove index.php
$config['index_page'] = ""

在 .htaccess 文件中写入以下代码

<IfModule mod_rewrite.c>
 RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

【讨论】:

  • 是的,我也这样做了,但我没有得到结果。我在根目录下的 .htaccess 中添加了这个。我还需要放在其他 .htacces 文件中吗?
【解决方案2】:
some cases the default setting for uri_protocol does not work properly. To solve this 
issue just open the file config.php located in application/config and then find and 
replace the code as:

  Find the below code

 $config['uri_protocol'] = "AUTO"

  Replace it as

 $config['uri_protocol'] = "REQUEST_URI" 

【讨论】:

    猜你喜欢
    • 2023-03-25
    • 2013-08-09
    • 2012-12-27
    • 1970-01-01
    • 1970-01-01
    • 2015-05-26
    • 1970-01-01
    • 2012-11-14
    • 2013-11-29
    相关资源
    最近更新 更多