2
I am working on an MVC project and I am having problems redirecting pages. The project is based on controllers and actions, that I have the proper functions that call these files and call their methods, in this case, the actions.
This is the HTML menu:
<li class="button"><a href="">To view this page in English</a></li>
<li class="button"><a href="apresentacao">Apresentação</a></li>
<li class="button"><a href="objetivos">Objetivos</a></li>
<li class="button"><a href="participantes">Participantes</a></li>
<li class="button"><a href="pesquisa">Pesquisas e Projetos</a></li>
When the URL is like this:
http://localhost/pasta_raiz/ ou
http://localhost/pasta_raiz/index
By clicking on a link in the menu, for example, presentation the redirect occurs correctly to the following link:
http://localhost/pasta_raiz/apresentacao
But when the Urls are with the action explicit, that is to say:
http://localhost/pasta_raiz/index/index
By clicking on link presentation, I’m referred to:
http://localhost/pasta_raiz/index/apresentacao
When the right thing would be:
http://localhost/pasta_raiz/apresentacao
And when I put it in the addresses href="/apresentacao"
I am referred to:
http://localhost/apresentacao
Resulting in a page not found. I don’t know what to do, what could be wrong?
Wouldn’t it be nice to put one
rtrim
in order to normalize the number of bars?rtrim(sprintf( 'http://%s/%s/', $_SERVER['HTTP_HOST'], $basepath ), '/');
– Wallace Maxters
As I made a mere adaptation when I had answered, I made it as simple as possible. If you check the original link source code you will see that there are other things besides a mere sprintf().
– Bruno Augusto