问题
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