[英]code igniter routing issues
我设置了重写规则
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
删除在我的URL中包括index.php的约束,并且我还设置了以下内容
$config['base_url'] = '';
$config['index_page'] = '';
我的自定义路线
$route['test/(:num)'] = 'test/view';
我的挑战是使用url http://localhost:8080/skillmerce
默认页面可以工作,但是每当我以http://localhost:8080/skillmerce/test/3
的形式访问url时,我都会收到404错误,但我更改了路由到类似
$route['skillmerce/test/(:num)'] = 'test/view';
请我如何解决这个问题,尝试设置基本URL,但都无济于事
您的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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.