从 htaccess 重写到 codeigniter 控制器
我的 codeigniter 应用程序目录结构类似于
--application
--htdocs
--index.php
--.htaccess
--文件夹
--file1.xml
现在我有一个网址 http://mysite.com/folder。这显示了文件夹目录中的文件列表。我想要的是将这个 url 重写为我网站上的控制器,即“html.php”。
注意:我不想重定向。我希望 url 相同,但不显示文件夹内容,而是希望将控件传递给控制器。我应该编写什么 .htaccess 规则?
My codeigniter application directory structure is like
--application
--htdocs
--index.php
--.htaccess
--folder
--file1.xml
Now I have a url http://mysite.com/folder. This is showing the files list in the folder directory. What I want here is to rewrite this url to a controller on my site say 'html.php'.
Note: I do not want to redirect. I want the url to be same but instead of showing folder contents, I want to pass the control to a controller. What .htaccess rule should I write?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你看过url路由吗?
即
$route['folder'] = "html"; //html 是您的控制器
www.yoursite.com/folder
将“重定向”到 yoursite.com/html 但不会更改 URL。
无需搞乱 htaccess
编辑:
从 - http://codeigniter.com/forums/viewthread/ 获得153228/
也许这就是你所追求的?
have you looked at url routing?
ie
$route['folder'] = "html"; //html is your controller
www.yoursite.com/folder
will "redirect" to yoursite.com/html but won't change the URL.
no need to mess with htaccess
edit:
obtained from - http://codeigniter.com/forums/viewthread/153228/
perhaps this is what you are after?