CodeIgniter重写URL:从URL中删除index.php [英] CodeIgniter Rewrite URL: remove index.php from url
问题描述
我的应用程序的网址是
http://localhost/myapp/admin/index.php/projects
我想将其重写为
http://localhost/myapp/admin/projects
我遵循了用户指南
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
推荐答案
感谢/ * ActuallyMAB * /:您的代码确实有效。上面的代码在localhost(Windows上的WAMP Server)上有效。
如果您已将codeigniter项目放置在某个文件夹中,例如目录结构,则如下所示:
Thank /* ActuallyMAB */: Your code actually works. The above code works on localhost (WAMP Server on windows). If you have placed your codeigniter project in some folder such as your directory structure looks like:
C:\wamp\www\proposal
因此,您必须替换
RewriteRule ^(.*)$ /project/index.php/$1 [L]
到
RewriteRule ^(.*)$ /proposal{or your folder name}/index.php/$1 [L]
如果您的项目不是这种情况{您已经将您的codeigniter直接放入www文件夹},然后从上面的代码中删除了该文件夹的名称;
if this is not the case with your project {you have put your codeigniter directly into www folder}, then remove the folder name from the above code as it looks like;
RewriteRule ^(.*)$ /index.php/$1 [L]
也不要忘记更改
$config['index_page'] = 'index.php';
至
$config['index_page'] = '';
在配置文件夹{config.php}
in your config folder {config.php}
我希望其他人也提供相同的答案,但是由于上述代码在我的项目中有效,因此我也想提供一些详细信息。
I hope others have also provided the same answer, but since the above code works in my project and i felt to provide some details too.
这篇关于CodeIgniter重写URL:从URL中删除index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!