【问题标题】:How to change URL in codeigniter如何在codeigniter中更改URL
【发布时间】:2014-05-09 05:37:48
【问题描述】:

当前我有 URL www.site.com/mauritius/className/function/id。 我已经设法使用 .htaccess 删除了 index.php

现在我想从 URL 中删除函数段。我想制作上面的网址 www.site.com/mauritius/className/id。 只是不希望 URL 中的“功能”仅用于一个功能。

【问题讨论】:

  • 我想实现上述 URL 的功能并显示不同的 URL。我可以使用路由来做到这一点吗?
  • 好吧,你没看。自己想办法。

标签: php .htaccess codeigniter url


【解决方案1】:

在 config/routes.php 中设置你的路由

$route['alias'] = 'controller/method';

或使用 .htaccess 重写 url

我不检查这个,但你可以试试

RewriteRule ^controller/([a-z0-9A-Z]+)/?$ controller/function/$1 [L,QSA]

更多信息:- http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/

【讨论】:

  • 我不想加载不同的方法。想要实现相同的功能,但只想重写 URL。要从 URL 功能中删除方法将与在同一方法中定义的相同。
  • 你能告诉我在 .htaccess 中写什么来删除它。谢谢
猜你喜欢
  • 2010-11-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多