codeigniter从URL中删除的index.php [英] Codeigniter remove /index.php from URL

查看:124
本文介绍了codeigniter从URL中删除的index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好了,所以我知道有很多人一直在问同样的或类似的问题,但我似乎没有找到一个解决方案,适用于我的项目。所以,请不要把这个作​​为一个重复的。

Okay so I know that a lot of people have been asking the same or similar questions, but I don't seem to find a solution that works for my project. So please don't put this as a duplicate.

我有codeigniter做一个网站。它运行得很好,而不在URL中的index.php。因此,改写了全成。直到前几天:忽然管理区(/管理)的返回404,是仅由路径/index.php/admin访问。一旦用于工作的重写code没有做的事情了。

I have a website made with codeigniter. It was running just fine without the index.php in the url. So the rewrite was successfull. Until a few days ago: all of a sudden the admin area (/admin) returned a 404 and was only accessible by the path '/index.php/admin'. The rewrite code that once used to work didn't do a thing anymore.

和知道我回到了起点 - > 的问题是,我不能删除我的网址在index.php

And know I'm back at the start -> the problem is that I cannot delete the index.php from my url.

我尝试了许多事情,我不知道该怎么办了。

I tried so many things that I don't know what to do anymore.

该应用程序的public_html /应用程序在存储/ ... 下图是应用程序所在的文件夹.htaccess文件和index.php文件都在里面。 这是正确的位置来改变的.htaccess?

The application is stored under 'public_html/application/... The image below is inside the application folder where the .htaccess file and index.php are. Is this the right location to change the .htaccess?

我试图重写的.htaccess但没有成功:

I tried rewriting the .htaccess but without success:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L] 

RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^CI/(index\.php|public|images|robots\.txt|css)
RewriteRule ^(.*)$ /index.php/$1 [L]

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

我的配置文件:

My config file:

$config['base_url'] = 'http://www.mysite.be/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

routes.php文件:

Routes.php:

$route['default_controller'] = "c_home/index";
$route['404_override'] = '';
$route['admin'] = "c_home/adminpanel";
$route['logout'] = "c_login/logout";

没有任何人有一个线索是怎么回事或者如何可以修复?

Does anybody have a clue what is going on or how this can be fixed?

在此先感谢!

推荐答案

所以,我一直在插科打诨本终于使工作

So I have been messing around with this and finally made it work

在此,我修改了htaccess的和控制器。
我改变了管理功能,新的控制器,并改变了这种在routes.php文件

For this I made changes to the htaccess and controllers.
I changed the admin function to a new controller and changed this in the routes.php

新的路由

$route['admin'] = "c_login/index";

新的.htaccess

new .htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L] 

这篇关于codeigniter从URL中删除的index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆