某些主机上的用户控制器区分大小写
我们通常使用两种不同的托管服务。一方面,一切都可以用 Ticketyboo 进行,就像在我的本地开发服务器上一样。然而,在另一台服务器上,我遇到了这个问题:
我无法像这样访问用户控制器: http://www.example.com/users/login
但我可以喜欢这样: http://www.example.com/Users/login
** 注意大写的“Users” ' **
如果我将应用程序转移到子文件夹中,一切都会正常工作(大写和小写)。
托管公司已经查看了它,并没有发现他们的问题,他们向我保证用户不是保留字。
您可能会说这不是问题,只需使用有效的版本即可。不幸的是,这会导致下游出现问题,Cake 核心开始自行生成 url。
其他人见过这个问题或知道解决方案吗?
[这只发生在用户控制器上 - 所有其他控制器都按预期工作]
We generally use two different hosting services. On one, everything works ticketyboo, as it does on my local dev servers. On the other server, however, I am having this problem:
I can't access the users controller like this:
http://www.example.com/users/login
But I can like this:
http://www.example.com/Users/login
** note the capitalised 'Users' **
If I displace the application to a sub-folder everything works fine (both upper- and lowercase).
The hosting company have looked at it and can't see a problem at their end and they assure me that users is not a reserved word.
You might say this isn't a problem, just use the version that works. Unfortunately it leads to problems downstream where Cake core starts generating urls itself.
Anybody else seen this problem or know the solution?
[This only occurs on the users controller - all others work as expected]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果没有看到您的所有代码/深入研究,我不确定这个问题的原因是什么。你的routes.php 文件中有一些特殊的东西吗?如果您为用户定义了特定的路线,那就可以了。
但是,您可以进行快速修复 - 在 UsersController(或 AppController,如果您想确保此行为不会在其他地方弹出)中,只需在 beforeFilter() 方法中添加一行以大写/取消大写(以更合适者为准)控制器参数。
[编辑] - 抱歉,没有完成第一段。它仍然可能是路由文件,即使它在一台服务器上运行而不是在另一台服务器上运行,因为工作服务器可能使用不区分大小写的 apache 模块来标准化所有 url。这就是为什么让您的登台和开发设置与生产环境完全相同的原因。
Without seeing all your code / diving in too deeply, I'm not sure what the cause of this problem is. Do you have some special stuff going on in the routes.php file? If you have a specific route defined for users, that could be it.
However, you could make a quick fix -- in UsersController (or AppController if you want to ensure this behavior doesn't pop up elsewhere) just add a line to the beforeFilter() method to capitalize / decapitalize (whichever is more appropriate) the controller parameter.
[edit] - sorry, didn't finish that first paragraph. It still could be the routes file, even though it works on one server and not the other, because it's possible that the working server uses a case-insensitive apache module that normalizes all urls. This is why it's so nice to have your staging and dev setups being EXACTLY the same as production.
虽然托管支持否认“用户”或“用户”一词以任何方式保留,但似乎是:
问题已解决。
While the hosting support denied that the word 'user' or 'users' or 'Users' was in any way reserved, it seems that it was:
Problem solved.