views:

37

answers:

4

Hi All:

I have an issue with not getting the correct relative url.

Right now, say my home page is at (please ignore quotation)

"http://www.foo.com/user/home"

I have links on the homepage that should go to

"http://www.foo.com/user/home/page1"

but right now I'm getting

"http://www.foo.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

A: 

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

Simon Brown
A: 

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.

d11wtq
A: 

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.

dhofstet
A: 

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).

Leo