简体   繁体   English

CodeIgniter删除index.php显示404

[英]CodeIgniter remove index.php displays 404

I know that this subject has been seen many times here, but I didn't see any of them solving my issue here... 我知道这个主题在这里已经被看到很多次了,但是我没有看到他们在这里解决我的问题...

I have an application that is working with Codeigniter. 我有一个使用Codeigniter的应用程序。 I try to remove the index.php in the URL, but it seems I'm cursed today. 我尝试删除URL中的index.php,但是今天我似乎受到了诅咒。

Here's what I have in my config.php file : 这是我的config.php文件中的内容:

$config['base_url']   = "http://".$_SERVER['SERVER_NAME']."/";
$config['index_page']    = "";
$config['uri_protocol']  = 'AUTO';

And here's my .htacess (such as CI suggests) : 这是我的.htacess(如CI建议):

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

With this, I'm unable to remove the index.php in the URL. 这样,我无法在URL中删除index.php。 In fact, it removes it well, but I have a pretty 404 then on the screen. 实际上,它可以很好地删除它,但是我在屏幕上看到了漂亮的404。

I checked the phpinfos() to see if the mod_rewrite was rightly activated, and there's no problem on this side. 我检查了phpinfos()来查看是否正确激活了mod_rewrite,并且这一方面没有问题。

**EDIT** **编辑**

I checked my apache logs, and here's what I have : 我检查了我的apache日志,这是我所拥有的:

[Wed Jul 18 12:27:08 2012] [error] [client 127.0.0.1] File does not exist: [PATH]/trunk/user

The real path should be : 真正的路径应该是:

[PATH]/trunk/application/controllers/user

I saw that all this stuff is setup in the index.php file, but it seems that it's never called... 我看到所有这些东西都是在index.php文件中设置的,但似乎从未调用过...

Could anyone suggests me something please to solve this ? 有人可以建议我解决这个问题吗?

Thanks ! 谢谢 !

Try this one: 试试这个:

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

The first condition makes sure the request isn't for a valid file and the second makes sure it isn't for a valid directory. 第一个条件确保该请求不是针对有效文件,第二个条件确保该请求并非针对有效目录。 All requests for files or folders that don't actually exist in the file system are sent through index.php. 文件系统中实际上不存在的所有文件或文件夹请求都通过index.php发送。

您不能阻止对index.php页面的访问,因为它是CI所基于的主页。

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

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