zf2 website with a single entry-point, no routes/paths in URL

自古美人都是妖i 提交于 2019-12-25 02:38:10

问题


Is it be possible to make a website that doesn't reveal any relative URL's at all? Say for example, I have a domain name "somedomain.xyz" and I want to route everything through the default route, and I want not to reveal any paths or route structures to the end user. The end user shall only see the domain name in the browser's address bar, like:

     http://somedomain.xyz 

or

    https://somedomain.xyz.

Any path like

  http://somedomain.xyz/index.php 

or

   http://somedomain.xyz/index or 
   http://somedomain.xyz/index/index 

shall show a 404. And I don't care about SEO stuff and static pages. Is that possible with ZF2, and if yes, then how?

similar question: hide module and action name from zf2 routing


回答1:


Just create a hostname route for subdomain.xyz like so:

'my-route' => array(
    'type' => 'Hostname',
    'options' => array(
        'route'    => 'subdomain.xyz',
        'defaults' => array(
            'controller' => 'MyApp\Controller\TheController',
            'action'     => 'whatever-action',
        ),
    ),
),



回答2:


see here for a complete solution, with using HTTP POST vars for the routing: ZF2 routing via post vars



来源:https://stackoverflow.com/questions/20160689/zf2-website-with-a-single-entry-point-no-routes-paths-in-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!