Reputation: 8981
I've got a php file inside this folder structure:
Web -> script -> gen.php
From this gen.php I want to redirect with the location()
function in Javascript to
Web->Index.html
I tried to do it like this:
location = "localhost/Web/index.html"
But I only get a 404 error
saying that this path is invalid. What is the correct way to do this?
Upvotes: 0
Views: 90
Reputation: 35582
write location = "http://localhost/Web/index.html"
instead. you missed to add http://
OR location = "index.html"
if you are in the same directory
Upvotes: 2
Reputation: 944076
location
, in JavaScript, is not a function. It is a property that you can assign a value to.
Any of (assuming Web is exposed on the URL and isn't just an internal directory):
http://localhost/Web/index.html
//localhost/Web/index.html
/Web/index.html
index.html
However, redirects should usually be handled with HTTP, so you are likely better off with:
<?php
header('Location: http://localhost/Web/index.html');
exit;
?>
(Note that while most browsers will recover from a relative URI in the location header, the specification requires an absolute URI).
Upvotes: 4