Programatic php 'a' link goes to 403

Username (e.g. epiz_XXX) or Website URL

listaescuelasmoron.infinityfreeapp.com/hacer_agregar_mensaje.php

Error Message

403: Forbidden

Other Information

Here’s the php echo code that puts a button on the web page:

echo "<a href=\"listaescuelasmoron.infinityfreeapp.com/index.php\"><button>Volver al inicio</button></a>";

When I click on that button, I end up at a beautiful “403: Forbidden”, instead of the main page of my site.
How can I effectively add a “Go to Home” button and make it work? Is it the “A” anchor tag? is it sth else?
I already tried setting up the button outside the php script, and be plain HTML instead of the effect of “echo” (not sure how that would change anything, echo is just the same as writing the pure html right down on the document itself).

echo '<a href="/"><button>Volver al inicio</button></a>';
2 Likes

I don’t think the URL href=\"listaescuelasmoron.infinityfreeapp.com/index.php\" goes where you think it goes.

If you specify a URL like that, it’s assumed to be a path. So if you are currently on the URL http://listaescuelasmoron.infinityfreeapp.com/blog/article.html, that link will go to the URL http://listaescuelasmoron.infinityfreeapp.com/blog/listaescuelasmoron.infinityfreeapp.com/index.php, which is probably not what you want.

This StackOverflow answer has a quite detailed explanation on how you can write URLs, and how they will be interpreted:

4 Likes

This worked.
I don’t know why, but it leaves me with a strange feeling, like the answer was so simple and beginner-level, that I can’t believe I didn’t figure it out myself earlier.
Thank you all who contributed with an answer.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.