doufu9947 2015-09-19 05:12
浏览 62

Zend Framework 1 - 隐藏URL中的索引操作

I have these URL's like

www.xyz.com/blog/index
www.xyz.com/tutorial/index

etc - Because I dont want the index to be shown in the URL - I have written routes to fix this issue:

resources.router.routes.blog.route = "/blog/"
resources.router.routes.blog.defaults.controller = blog
resources.router.routes.blog.defaults.action = index

So now when a user types

www.xyz.com/blog - the index action opens up.

What I want is - when a user enters www.xyz.com/blog/index -

it should get redirected to www.xyz.com/blog

Basically the index should not show up in the URL whether or not the user enters it in the URL - How can I achieve this?

Thanks

  • 写回答

2条回答 默认 最新

  • dongyupan4850 2015-09-19 06:41
    关注

    Assuming you don't actually have a blog controller, I just give you an example code you can add this:

    resources.router.routes.default.chains.index.type = "Zend_Controller_Router_Route"
    resources.router.routes.default.chains.index.route = "blog/"
    resources.router.routes.default.chains.index.defaults.controller = "blog"
    resources.router.routes.default.chains.index.defaults.action = "index"
    

    and now www.xyz.com/index/blog and www.xyz.com/blog will both work and end up at the same place.

    评论

报告相同问题?

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算