如何重写URL在codelgniter [英] How to rewrite url in codelgniter

查看:128
本文介绍了如何重写URL在codelgniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好首先,我告诉大家,在codelgniter框架我是新的,我已经与我的网址有问题的URL看起来像这样 http://www.vacationplannersnetwork.com/search/name/france

Hello First i tell all of you that in codelgniter framework i am new and i have a problem related to my url the url looks like this http://www.vacationplannersnetwork.com/search/name/france

但我希望我的URL看起来像这样 http://www.vacationplannersnetwork.com/france

but i want my URL looks like this http://www.vacationplannersnetwork.com/france

我做搜索这个网站的引擎优化,所以我想这种类型的结构,因此,如果有人知道的话请帮我其高度recommended.thanks先进的。

I do search engine optimization of this website so i want this type of structure ,so if anyone knows then please help me its highly recommended.thanks in advanced.

推荐答案

这是可以做到在rerouteing。 在你的 APPPATH。 routes.php文件文件中加入这一行:

It can be done over rerouteing. In your APPPATH . 'routes.php' file add this line:

$route['(:any)'] = 'search/name/$1';

既然你想有第一个URI段相匹配的结果

,您将需要一个前添加其他特定的路线。例如:

Since you want to have first URI segment matching your results, you would need to add other specific routes before that one. For example:

$route['contact-us'] = 'public_controller/contact_method';
$route['aboout-us'] = 'public_controller/aboutus_method';
/*
 * other routes
 * here
 */
$route['(:any)'] = 'search/name/$1';

文档

此外,如果需要的话不要忘记更改链接锚鉴于文件(静态页面/变量)。

Also, don't forget to change links anchor in view files if needed (for static pages/variables).

这篇关于如何重写URL在codelgniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆