[英]URL rewriting using Codeigniter for specific rule
On my local server, I have setup a website using Codeigniter which opens up fine using below URL 在我的本地服务器上,我使用Codeigniter设置了一个网站,该网站可以使用以下URL打开
I have a different kind of query regarding rewriting URL 关于重写URL,我有另一种查询
http://localhost/mywebsite
Actually the real URL is below 实际的网址实际上在下面
http://localhost/mywebsite/page/
Which I want it to work as root url as 我希望它作为根URL工作
http://localhost/mywebsite
So I have done it by adding it as default controller in config.php 所以我通过将它添加为config.php中的默认控制器来完成它
But now I have another URL as 但是现在我有另一个网址
http://localhost/mywebsite/page/mypagename
Which should open as 哪个应该打开为
http://localhost/mywebsite/mypagename
How can I do it? 我该怎么做?
You can define a custom route in /system/application/config/routes.php - for example: 您可以在/system/application/config/routes.php中定义自定义路由-例如:
$route['abc'] = 'controller_name/abc';
Then, http://mydemosite.com/abc
goes to http://mydemosite.com/controller_name/abc
see https://ellislab.com/codeigniter/user-guide/general/routing.html for more information of URI Routing. 有关URI路由的更多信息,请参见https://ellislab.com/codeigniter/user-guide/general/routing.html 。
I hope this can be helping you. 希望对您有所帮助。
我使用下面的config / routes.php下的路由方法解决了它
$route['([^/]+)/?'] = 'page/$1';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.