简体   繁体   English

代码点火器清理URL

[英]Code Igniter Clean URL

I'm dealing with this URL. 我正在处理此URL。 I'm workin on a proyect where I've have this URL: 我在一个拥有以下URL的proyect上工作:

http://localhost/franca/menkenPh/index.php/controller/argument/argument

But I need that i turns into something like: 但我需要我变成这样的东西:

http://localhost/franca/menkenPh/0/cirug

How can I achive that? 我该如何实现?

I try to do this on the .htaccess: 我尝试在.htaccess上执行此操作:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /franca/menkenph/
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

But when I go to URL I want it give me page not found error and when i do: 但是当我转到URL时,我希望它给我页面未找到错误,而当我这样做时:

    http://localhost/franca/menkenPh

It tells me that the arguments are missed. 它告诉我,这些论点被遗漏了。

Any clue? 有什么线索吗?

Go to your application/config/config.php remove index.php from the base url. 转到您的application / config / config.php从基本URL中删除index.php。

/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|   http://example.com/
|
| If this is not set then CodeIgniter will guess the protocol, domain and
| path to your installation.
|
*/
$config['base_url'] = 'http://localhost/franca/menkenPh';

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';

Then go to your routes the add 然后去你的路线添加

$route['/(:any)/(:num)'] = "maincontroller/index/$1/$2";

So the method should be index() but no arguments at all just use uri class and locate those two uri segments 因此,该方法应为index(),但完全没有参数,仅使用uri类并找到这两个uri段

$arg1 = $this->uri->segment(3,0);
$arg2 = $this->uri->segment(4,0);

Your rewrite base should be 您的重写基础应该是

RewriteBase /franca/menkenph/
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /franca/menkenPh/index.php?/$1 [L]

Try this htaccess 试试这个htaccess

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM