Zend Framework htaccess 后端/前端
在我当前的 ZF 项目中,我有两个公共访问点(文件)准备好处理和处理。处理即将到来的请求,即:index.php & admin.php
我需要将所有包含“/admin”的 URL 路由到 admin.php,而任何其他不包含“/admin”的 URL 则路由到 index.php
ZF htaccess 包含以下规则:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
知道默认 可以实施吗?
In my current ZF project, I've two public access points (files) ready to handle & process coming requests, that's: index.php & admin.php
I need all URLs containing '/admin' to be routed to admin.php while any other URLs doesn't contain '/admin' to be routed to index.php
Knowing that default ZF htaccess contains the following rules:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
How this can be implemented?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先我想说我完全同意奥雷利奥·德罗萨的观点。我相信路线将是更好的选择。然而,这是你的选择,不是我的,这个 .htaccess 代码应该可以达到你想要的效果。
但请注意,此脚本将捕获任何包含 admin 的内容,因此可能会破坏您的前端。例如,如果您想列出所有具有管理权限的用户,则 url yoursite.com/users/listby/admin/ 会将请求重定向到 admin.php,像 /administrator/ 这样的 url 也会重定向到 admin.php或 /adminininini
I want to start by saying that I full heartedly agree with AurelioDeRosa. I do believe that routes will be a better choice. However that is your choice not mine and this .htaccess code should do the trick you want.
Note however that this script will catch anything that contains admin so it might break your frontend. for example, if you want to list all your users with administrative rights the url yoursite.com/users/listby/admin/ will redirect the request to admin.php, and so will urls like /administrator/ or /adminininini