[英]codeigniter htaccess
我在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
你能帮我么 ?
首先,应在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错误:
Cherry将您的config.php
分开。 发生了很多变化,因此最好使用vanilla 2.1版本,并使用1.7版本中以前配置的变量进行填充。 同样的情况也适用于application/config
文件夹中的某些其他文件。
更改日志对特定细节无穷无尽: http : //codeigniter.com/user_guide/changelog.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.