Codeigniter 3.1.6-如何从URL中删除index.php [英] Codeigniter 3.1.6 - How to remove index.php from url
问题描述
我正在使用Codeigniter 3.1.6。
I am working on codeigniter 3.1.6.
我添加了.htaccess文件。
我还将 base_url
路径更改为我的项目路径,从<$ c中删除了 index.php
$ c> index_page 并将 url_protocol
更改为 REQUEST_URI
。
I added the .htaccess file.
I also changed the base_url
path to my project path, removed the index.php
from index_page
and changed the url_protocol
to REQUEST_URI
.
尽管如此,当我将URL重定向到任何控制器方法时,它会引发错误,显示为 未找到您所请求的页面
。
Still, while I am redirecting the url to any controllers method it throwing an error as 'The page you requested was not found
.'
我也搜索并应用了不同的.htaccess文件,但它不起作用。
如果我在base_url的末尾添加 /index.php
,则它可以正常工作,但是它是错误的。 b
$ b
请注意:codeigniter-3.1.4只能在此版本下正常工作
I also searched and applied different .htaccess but its not working.
If I am addling /index.php
at end of base_url then its working but its wrong though. It should work without index.php.Only 3.1.6 giving this issue.
p>
推荐答案
将文件夹名称 CodeIgniter-3.1.6
更改为 ci
将您的 base_url
设置为
$config['base_url'] = 'http://localhost/ci/
使用此 .htaccess
RewriteEngine On
RewriteBase /ci
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
这篇关于Codeigniter 3.1.6-如何从URL中删除index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!