Javascript/PHP: Page redirection

Asked

Viewed 742 times

0

Good evening, I am a complete beginner in web development, and after several google searches, I did not get a satisfactory answer.
I’m using the command window.location.href to redirect my system pages, but since they are on localhost, I am only using basic paths, example: window.location.href="../pages/pagina.php"; or even window.location.href="pagina.php"(when they are in the same directory).

My question is this: when climbing to a web server, will this give any problem? I would need to put the full path, like "http://..."?
Thank you for your attention.

  • 1

    No @Raphaelhenrique , it will work smoothly, just need to add a bar there / in the second example - window.location.href="/pagina.php" otherwise he’ll just add pagina.php at the end of the URL instead of even going to the page, it will be dominio.com/pagina.php

1 answer

2


No, the only situation that can give problem is if you are specifying the path from the beginning, example window.location.href = http://localhost/pagina.

While you use ../ (back directory) or by specifying a direct page (no bar at the beginning) it will be relative to current url.

Example:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.