I want to change the URL via PHP.
Something like window.location.href = "http://www.something.com" in JavaScript.
window.location.href = "http://www.something.com"
I want the same thing, but in PHP. How can i do this?
To do this, you can use the header function:
header
header("LOCATION: http://www.something.com");
You can use the header () command:
<?php header("Location: http://www.example.com/"); ?>
<?php header('Location: http://www.example.com/'); ?>
Make sure there is nothing above the output line, otherwise it will fail.
You can use ob_start along with the header to prevent redirection errors:
<?php ob_start(); // Starts Output Buffering header(/*Your redirection location*/); // Redirects user to given location. ?>