本文介绍了如何从CodeIgniter中的URL删除控制器和函数名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用CI开发的一个应用程序遇到了严重问题.目前,我的网址看起来像这样

I am having a serious issue with one application developed in CI.Currently my URLs look like this

http://www.example.com/content/index/mission/

我想从URL中删除/content/index/,因此,它应该看起来像这样.

I want to remove /content/index/ from URL So, It should look something like this.

http://www.example.com/mission

我也有路由和.htaccess方法.但是似乎没有任何效果.

I have routing and .htaccess method as well. But nothing seems to be working.

这是我的.htaccess文件

Here is my .htaccess file

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|images|css/js/style/system/feature_tab/robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [QSA,L]

我也尝试通过在config/router.php中定义reouters来尝试路由CI,但是它不起作用:(

I have also tried routing of CI by defining reouters in config/router.php But it was not working :(

推荐答案

对于您的特定示例,您将要创建一个映射路径(在application/config/routes.php中)

For your specific example, you'll want to create a route (in application/config/routes.php) that maps

$route['mission/']

"content/index/mission"

换句话说,$route['mission/'] = "content/index/mission";

有关更多信息,请参见有关URI路由的CI文档

See the CI documentation regarding URI routing for more info

这篇关于如何从CodeIgniter中的URL删除控制器和函数名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 13:16