Hello I have a problem with header('Location: http://www.example2.com/');
while there is a query string.
Ok I will make the question easy to understand:
now I have a domain name http://example1.com/?url=url
I want when someone want to access example1.com it redirects him to example2.com but if he types example1.com/?url=url nothing will happen so how can I do that please and thanks in advance
I assume you have index.php in root directory of domain example1.com
. And you can use this;
<?php
if (empty($_GET["url"])) {
header("Location: http://www.example2.com/");
}
What do you use for redirecting? From your post's first line I assume, that you're redirecting the user via the PHP header
function. So, check in PHP whether there is a query string or not:
<?php
if (empty($_SERVER["QUERY_STRING"]))
{
header("Location: http://www.example2.com/");
}
?>