这是我的 CodeIgniter Controller 类代码。
class View extends MY_Controller
{
function index($number)
{
.....
}
.......
}
通过浏览器,我可以使用这个 URL 访问 View 类的索引方法
http://localhost/view/index/12
所以,我的问题是
有没有什么有效的方法可以改写URL,比如改成这个URL
http://localhost/view/12
我的网络服务器是 Nginx。
最佳答案
index()
默认被调用,但如果你想为其他功能做它,你可以利用 CI 中的 URI 路由功能。
将此添加到配置目录中的 routes.php。
$route['view/(:num)'] = "view/index/$1";
关于php - Nginx 服务器的 CodeIgniter URL 重写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6371767/