1

我在 codeigniter 1.7 上有一个大应用程序,我将其更新到 2.1,但我有一个问题(404 页面未找到)我当前的 htaccess 是:

rewriteEngine on
Options +FollowSymLinks

rewriteRule ^admin(.*) index.php/admin$1
rewriteRule ^supervisor/([0-9]+)(.*) index.php/supervisor_$1/$2
rewriteRule ^(login|logoff)(.*) index.php/base/$1$2
rewriteRule ^(files|attachment|meeting|thread|attachments|profile|search|roles|cat)(.*) index.php/moder/$1$2
rewriteRule ^(about|contact|new_majlis|stats)(.*) index.php/page/$1$2
rewriteRule ^(2.2-release-notes)(.*) index.php/page/release_notes

你能帮我么 ?

4

1 回答 1

0

首先,应该在您的application/config/routes.php文件中完成这样的路由。我建议添加以下条目:

$route['supervisor/(:num)/(:any)'] = 'supervisor/$1/$2'; // This also looks hackish
$route['login/(:any)'] = 'base/$1';
$route['logoff/(:any)'] = 'base/$1';


$route['about/(:any)'] = 'page/about/$1';
$route['contact/(:any)'] = 'page/contact/$1';
$route['new_majlis/(:any)'] = 'page/new_majlis/$1';
$route['stats/(:any)'] = 'page/stats/$1';
$route['2.2-release-notes/(:any)'] = 'page/stats/$1';

我还假设您想要拥有“漂亮”的页面;/admin而不是/index.php/admin

对于您的.htaccess文件,您可以将以上所有内容替换为:

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

这将确保 CodeIgniter 正在处理所有请求。


对于您的 404 错误:

樱桃采摘你的config.php。很多事情都发生了变化,所以最好使用 vanilla 2.1 版本并用您之前配置的 1.7 版本的变量填充它。这同样适用于您application/config文件夹中的其他一些文件。

更改日志对细节非常有用:http ://codeigniter.com/user_guide/changelog.html

于 2012-04-18T17:21:29.573 回答