我有以下网址..
http://localhost/ci/site_controller/home
我想从 url 中删除 site_controller controller 导致..
I want to remove site_controller controller from url resulting in..
http://localhost/ci/home
如何在 CodeIgniter 中执行此操作?
How can I do this in CodeIgniter ?
注意:如果你问我尝试了什么,而不是我刚刚在谷歌上搜索过,因为我不知道如何使用 mod_rewrite.
Note: If you'll ask what I've tried than I've just done searching over Google as I don't know how to use mod_rewrite.
编辑
我的routes.php中有这个
I have this in my routes.php
$route['default_controller'] = "site_controller/home";
$route['ci/home'] = 'ci/site_controller/home';
$route['404_override'] = '';
但还是不行!
.htaccess
RewriteEngine On
RewriteBase /ci/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
ErrorDocument 404 /index.php
您可以为每个 url 设置路由:
You can set your a route for each url:
在你的 config/routes.php 文件中,像这样设置每个页面:
In your config/routes.php file, just set each page like this:
$route['ci/home'] = "ci/site_controller/home";
这篇关于如何从 url 中删除控制器名称使其在 codeigniter 中干净的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
Zend 中的动作视图助手 - 解决方法?Action View Helper in Zend - Work around?(Zend 中的动作视图助手 - 解决方法?)
这是将 URI 与 PHP 中用于 MVC 的类/方法匹配的好方Is this a good way to match URI to class/method in PHP for MVC(这是将 URI 与 PHP 中用于 MVC 的类/方法匹配的好方法吗)
我在哪里保存 Zend Framework 中的部分(视图),以便Where do I save partial (views) in Zend Framework, to be accessible for all Views in my App?(我在哪里保存 Zend Framework 中的部分(视图),以
有一个网站的单一入口点.坏的?好的?没问题?Having a single entry point to a website. Bad? Good? Non-issue?(有一个网站的单一入口点.坏的?好的?没问题?)
MVC + 服务层在 Zend 或 PHP 中常见吗?Is MVC + Service Layer common in zend or PHP?(MVC + 服务层在 Zend 或 PHP 中常见吗?)
PHP MVC 方法中的 Hello World 示例Hello World example in MVC approach to PHP(PHP MVC 方法中的 Hello World 示例)