【发布时间】:2014-02-28 15:51:10
【问题描述】:
好的,我知道很多人一直在问相同或相似的问题,但我似乎没有找到适合我的项目的解决方案。所以请不要把它当作重复。
我有一个使用 codeigniter 制作的网站。如果没有 url 中的 index.php,它运行得很好。所以重写成功。直到几天前:突然间管理区域(/admin)返回了 404 并且只能通过路径 '/index.php/admin' 访问。曾经可以工作的重写代码现在已经没有任何作用了。
知道我又回到了起点 -> 问题是我无法从我的网址中删除 index.php。
我尝试了很多我不知道该怎么做的事情。
应用程序存储在 'public_html/application/... 下图位于 .htaccess 文件和 index.php 所在的应用程序文件夹中。 这是更改 .htaccess 的正确位置吗?
我尝试重写 .htaccess 但没有成功:
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]
我的配置文件:
$config['base_url'] = 'http://www.mysite.be/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
Routes.php:
$route['default_controller'] = "c_home/index";
$route['404_override'] = '';
$route['admin'] = "c_home/adminpanel";
$route['logout'] = "c_login/logout";
有人知道发生了什么或如何解决这个问题吗?
提前致谢!
【问题讨论】:
-
您的 apache 日志中是否有任何错误?并启用双重检查 mod 重写以防万一。
标签: php .htaccess codeigniter