Hi.
I am using the book PHP & MySQL: Novice to Ninja.
I’m having a problem with repeated controllers in the URL. Here’s what’s happening.
I have table in my website called “pages” which contains the text for a number of miscellaneous pages: privacy policy, about us, etc. As these pages are all in the same table, I have created a single action called “display” to which I pass a page_id. I have a controller, “Page” which contains this action.
The links to these pages are in the footer of “layout.html.php”, a master page, so they are on every page. The links are hard-coded like so:
<li><a href="page/display?id=84">About Us</a></li>
<li><a href="page/display?id=134">Find Us</a></li>
When the site is first loaded, if I hover over any of these links, they show:
“www.domain.local/page/display?id=84”, etc.
That’s exactly what I would expect: one controller (“page”). And the url will say:
“http://www.domain.local/page/display?id=134
” or such.
BUT, if I click on one of the links, the page is displayed properly with a url like above, but then all the other links (when hovering over them) look like this:
“www.domain.local/page/page/display?id=84”
A doubled, controller.
I also have other links around the master page which involve completely different controllers, say “Service” with links like:
“www.domain.local/service/display?id=123”
If I click one of these, just after the site is first loaded, the service page will load properly with a url like so:
“http://www.domain.local/service/display?id=33
” (one controller)
but then all other links (when hovered) will look like this:
“www.domain.local/service/service/display?id=456”
or
“www.domain.local/service/page/display?id=84”
Basically, if I click a link, the controller that link routes through appends itself to “www.domain.local” so the routes of other links are added AFTER this controller, hence a repeated controller, or two different controllers.
Interestingly, if I click on the link for the Home page, which has a route of an empty string, the other links go back to displaying a single controller when hovered.
I have xDebugged and cannot find where this is happening. xDebug reports the route correctly as just service/display or page/display. The problem seems to be with the url BEFORE that.
Anyone had any experience of this? Any ideas WHERE to look for the problem?
Cheers.