代码点火器URL路由混淆

时间:2012-01-24 16:13:11

标签: codeigniter

我有一个小问题。我已将默认控制器配置为:

c$route['default_controller'] = 'news';

因此,当我将浏览器指向http://localhost/mysite时,所有新闻都会按照新闻控制器的指示加载。 现在在这个页面上,我已经给出了“阅读文章”的链接来阅读完整的文章。为此,我必须将浏览器指向http://localhost/index.php/news/view/news-slug。我想从网址中删除index.php。我已经尝试使用通配符重新路由而没有任何成功。你能告诉我怎么做吗?

2 个答案:

答案 0 :(得分:4)

如果你使用Apache index.php,那么有关于从网址中删除mod_rewrite的文档:

使用以下重写代码:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

此外,有许多类似的问题,请从搜索中查看这些问题:

答案 1 :(得分:0)

您需要为此定义.htaccess文件。检查此维基:http://codeigniter.com/wiki/mod_rewrite