开发者

case sensititivity with users controller on certain hosting

开发者 https://www.devze.com 2023-01-01 10:37 出处:网络
W开发者_Go百科e 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:

W开发者_Go百科e 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]


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:

"We have removed the users/ redirect"

Problem solved.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号