如何从URL中的codeIgnitor删除控制器和函数的名称 [英] How to remove Controller and function name from URL in CodeIgnitor
问题描述
我有一个应用程序的严重问题,在CI开发。 目前我的URL看起来像这样
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所以,它应该是这个样子。
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]
我也尝试过CI路由定义在配置/ router.php reouters但它不工作:(
I have also tried routing of CI by defining reouters in config/router.php But it was not working :(
推荐答案
有关您的具体的例子,你需要创建一个路由(在应用程序/配置/ 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"
在换句话说, $航线['使命/'] =内容/索引/任务;
请参阅有关URI路径的 CI文档以获取更多信息。
See the CI documentation regarding URI routing for more info
这篇关于如何从URL中的codeIgnitor删除控制器和函数的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!