如何最小化CodeIgniter 2.2.3中的url

如何最小化CodeIgniter 2.2.3中的url,codeigniter,Codeigniter,我是codeigniter的新手,我也喜欢在未来的项目中使用它。 我有一个大问题,使我的网址用户友好。 我有一个网站运行,有很多网页,所以网址变得太大,他们看起来太糟糕。 所以我想做的是缩短我的URL。例如: www.abc.com/index.php/main/home 我想做这样的东西: www.abc.com/home 所以我的问题是,我应该如何在CodeIgniter 2.2.3中实现这一点?有演示吗? 我看到了这么多的链接,但它不能满足我的要求,所以请帮助我。您可以使用路由来实现此

我是codeigniter的新手,我也喜欢在未来的项目中使用它。 我有一个大问题,使我的网址用户友好。 我有一个网站运行,有很多网页,所以网址变得太大,他们看起来太糟糕。 所以我想做的是缩短我的URL。例如:

www.abc.com/index.php/main/home
我想做这样的东西:

www.abc.com/home
所以我的问题是,我应该如何在CodeIgniter 2.2.3中实现这一点?有演示吗? 我看到了这么多的链接,但它不能满足我的要求,所以请帮助我。

您可以使用路由来实现此目的

要删除index.php,请使用带有以下代码的.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
在config.php中

现在在routes应用程序/config/routes.php中

要删除index.php,请将.htaccess放在应用程序文件夹根目录之外

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>
例: 用这个


谢谢你,伙计。问题出在我的C:\wamp\bin\apache\apache2.4.9\conf/httpd配置文件中。。因此,我取消了通信重写模式,所以它很好,现在工作得很好。再次感谢您宝贵的时间和建议。感谢老兄。问题出在我的C:\wamp\bin\apache\apache2.4.9\conf/httpd配置文件中。。因此,我取消了通信重写模式,所以它很好,现在工作得很好。再次感谢您宝贵的时间和建议。。
$route['home']='main/home';
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>
$route['home'] = "main/home";
Firstly i create .htaccess file and put this code in it..

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /xyz.co/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
    </IfModule>

than go to application/config/routes.php and put below code.

$default_controller = "auth";
$controller_exceptions = array('main');
$route['default_controller'] = $default_controller;
$route["^((?!\b".implode('\b|\b', $controller_exceptions)."\b).*)$"] = $default_controller.'/$1';
$route['404_override'] = 'error';
$route['translate_uri_dashes'] = FALSE;

and in config.php

$config['uri_protocol'] = 'AUTO';

thats all...