I need to reroute a url here. I'm using teh end framework and need to set up some开发者_如何转开发 basic static pages here. LIke privacy policy, advertise etc - however the problem is that I need to create a controller for each and every page here. Thats not much of an issue but I was wondering if its possibel for me to set it up so:
mysite.com/privacy/index
would be rerouted to
mysite.com/pages/privacy
Might sound like a non issue but would like to know
For every static page, you can add a route for it in your application.ini. For example, for mysite.com/privacy/index
you can do:
resources.router.routes.privacy.route = "/privacy/index"
resources.router.routes.privacy.defaults.module = default
resources.router.routes.privacy.defaults.controller = pages
resources.router.routes.privacy.defaults.action = privacy
More about routing in ZF is in the ZF's manual. Hope this helps
From my experience I would STRONGLY discourage creating custom routes if not 100% needed (exception be urls with keywords for products or CMS generated pages). We wanted to our ecommerce solution to have nice urls like /about-us/
instead of /pages/about-us/
, but it's PITA to add any more features, as you had to add new route for every such thing. We currently have like 25 custom routes. You can never tell what the hack the url is because standard-url like producer/index
is routed from something like producers
.
If you still want it, follow Marcin's answer :)
精彩评论