【发布时间】:2017-12-13 01:45:34
【问题描述】:
我的网址是:
example.com/controller/function/parameter
=> example.com/category/index/category_name
我需要:
example.com/category/category_name
我已经尝试了 Stackoverflow 提供的几种解决方案,但都没有奏效。它要么重定向到家,要么重定向到404 page not found。
我尝试过的选项是:
$route['category'] = "category/index"; //1
$route['category/(:any)'] = "category/index"; //2
$route['category/(:any)'] = "category/index/$1"; //3
另一条路线是:
$route['default_controller'] = 'home';
htaccess 文件:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
在配置文件中我有:
$config['url_suffix'] = '';
【问题讨论】:
-
$route['category/(:any)'] = "category/index/$1"; //3这一定可以正常工作。我试过了。并得到正确的回应 -
我认为您只需要路线#3。你能展示你的类别控制器吗?
标签: php .htaccess codeigniter