使用搜索字词更改Codeigniter中的网址

用户名

我有这样的链接

http://example.com/search/texas

我希望它路由到控制器search,URL应该是

http://example.com/schools-in-texas

到目前为止我做了什么

在路线上

$route['search/(:any)'] = "search"; //search is a controller

在搜索控制器上,我texas使用

$x = $this->uri->segment(2);

我想查询数据库并使用结果来打开一个搜索模板,其中url是搜索项http://example.com/schools-in-texas哪里texas

我重定向到url,但未从数据库加载数据,因此无法按预期工作。

$url = $this->uri->segment(2);
redirect('schools-in-'.$url, 'refresh');

有人可以提供任何想法如何实现这一目标吗?

Rejoanul Alam

试试这个路由

$route['schools-in-(:any)'] = 'search';

这将考虑到Search控制器时,您的网址就会像http://example.com/schools-in-texas

为了texas从网址(用于搜索字词)中获取单词,您现在可以使用

$state_name = substr($this->uri->segment(1), strrpos($this->uri->segment(1), '-') + 1);

现在$state_name将输出,texas就像您输入URL http://example.com/schools-in-texas

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

CodeIgniter的“ like()”函数在搜索字词中带有%通配符

来自分类Dev

网址重定向,在codeigniter中更改或更改.htaccess

来自分类Dev

如果网址包含字词,则在iframe中隐藏div

来自分类Dev

在CodeIgniter中重写网址

来自分类Dev

我的搜索字词仅打印列表中的最后一个字词,而不是找到的字词[Python 2.7.6]

来自分类Dev

我的搜索字词仅打印列表中的最后一个字词,而不是找到的字词[Python 2.7.6]

来自分类Dev

阻止Chrome多功能框将搜索字词转换为网址

来自分类Dev

搜索该字词时未显示类别中的产品(Magento)

来自分类Dev

搜索该字词时未显示类别中的产品(Magento)

来自分类Dev

在Biopython中使用搜索字词返回登录号

来自分类Dev

在Biopython中使用搜索字词返回登录号

来自分类Dev

在python中更改网址

来自分类Dev

使用.htaccess更改网址

来自分类Dev

从/ auth / CodeIgniter和Ionauth更改网址路径

来自分类Dev

如何将查询字符串更改为codeigniter中的细分网址?

来自分类Dev

使用Codeigniter将网址更改为破折号而不是下划线

来自分类Dev

在CodeIgniter中搜索表格

来自分类Dev

codeigniter 中的搜索按钮

来自分类Dev

搜索字词更改时,AJAX自动完成列表有更新麻烦吗?

来自分类Dev

在特定字词之前搜索的出现

来自分类Dev

更改htaccess中的网址无效

来自分类Dev

使用mod重写更改网址

来自分类Dev

如何使用https://www.com删除codeigniter中的index.php。在网址中?

来自分类Dev

在php搜索框中显示网址

来自分类Dev

如何从搜索栏中复制网址?

来自分类Dev

搜索表单以在网址中添加“ sku”

来自分类Dev

获取漂亮的网址以显示在Google搜索中

来自分类Dev

删除CodeIgniter网址中的“视图”部分

来自分类Dev

CodeIgniter从网址中删除index.php

Related 相关文章

  1. 1

    CodeIgniter的“ like()”函数在搜索字词中带有%通配符

  2. 2

    网址重定向,在codeigniter中更改或更改.htaccess

  3. 3

    如果网址包含字词,则在iframe中隐藏div

  4. 4

    在CodeIgniter中重写网址

  5. 5

    我的搜索字词仅打印列表中的最后一个字词,而不是找到的字词[Python 2.7.6]

  6. 6

    我的搜索字词仅打印列表中的最后一个字词,而不是找到的字词[Python 2.7.6]

  7. 7

    阻止Chrome多功能框将搜索字词转换为网址

  8. 8

    搜索该字词时未显示类别中的产品(Magento)

  9. 9

    搜索该字词时未显示类别中的产品(Magento)

  10. 10

    在Biopython中使用搜索字词返回登录号

  11. 11

    在Biopython中使用搜索字词返回登录号

  12. 12

    在python中更改网址

  13. 13

    使用.htaccess更改网址

  14. 14

    从/ auth / CodeIgniter和Ionauth更改网址路径

  15. 15

    如何将查询字符串更改为codeigniter中的细分网址?

  16. 16

    使用Codeigniter将网址更改为破折号而不是下划线

  17. 17

    在CodeIgniter中搜索表格

  18. 18

    codeigniter 中的搜索按钮

  19. 19

    搜索字词更改时,AJAX自动完成列表有更新麻烦吗?

  20. 20

    在特定字词之前搜索的出现

  21. 21

    更改htaccess中的网址无效

  22. 22

    使用mod重写更改网址

  23. 23

    如何使用https://www.com删除codeigniter中的index.php。在网址中?

  24. 24

    在php搜索框中显示网址

  25. 25

    如何从搜索栏中复制网址?

  26. 26

    搜索表单以在网址中添加“ sku”

  27. 27

    获取漂亮的网址以显示在Google搜索中

  28. 28

    删除CodeIgniter网址中的“视图”部分

  29. 29

    CodeIgniter从网址中删除index.php

热门标签

归档