我已经设置了重写规则
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
删除我的网址中包含index.php的约束,我也设置了以下内容
$config['base_url'] = '';
$config['index_page'] = '';
我的自定义路线
$route['test/(:num)'] = 'test/view';
我的挑战是我的默认页面,网址为http://localhost:8080/skillmerce
,但每当我有http://localhost:8080/skillmerce/test/3
形式的网址时,我会收到404错误,除非我将路线更改为
$route['skillmerce/test/(:num)'] = 'test/view';
请问我怎么解决这个问题已经设置了基本网址,但一切都无济于事
答案 0 :(得分:0)
你的htaccess将是
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|image|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
在config.php中
$config['base_url'] = 'http://stackoverflow.com/';
$config['index_page'] = ''; # leave this as empty
和路线
$route['skillmerce/test/(:num)'] = 'test/$1'; # add $1 at the end