Redirecting to wrong relative address
I have an issue with not getting the corre开发者_StackOverflow社区ct relative url.
Right now, say my home page is at
http://www.example.com/user/home
The links on the homepage should go to:
http://www.example.com/user/home/page1
But I'm getting:
http://www.example.com/page1
Everything worked locally. Can this be fixed with modifying .htaccess
and how? Thank you.
ps. I can edit the links on the index page to go to the correct address, but some of the internal functions (like login) are still going to the wrong place
Check that you don't have any base tags on the page.
The tag specifies a default address or a default target for all links on a page.
http://www.w3schools.com/tags/tag_base.asp
I don't know CakePHP but I do know URLs and:
/user/home + page1 => /user/page1
However:
/user/home/ + page1 => /user/home/page1
It's the browser's responsibility to determine the relative path (assuming you just dropped the link into the page), not Cake's.
I'd need to see some code to better understand your situation.
I think you have to set the RewriteBase
in your .htaccess files, see http://book.cakephp.org/view/37/Apache-and-mod_rewrite-and-htaccess and the Apache documentation.
You're not giving us a lot to go on.
Controller names in CakePHP are generally plural: 'users' not 'user'. If you're using the helpers to write the URLs, it maybe that for this reason Cake can't find them and is defaulting to the webroot.
A code fragment from the .ctp file would really help us to help you (as well as routes.php if you've changed it).
精彩评论