Pergunta

I want to place links on my page.

I use

echo "<a href=\"".$_SERVER['HTTP_HOST']."/projecten/project.php?project=1";

I want to go to mydomain.nl/project/project.ph?project=1 but instead of that link I get http://mydomain.nl/projecten/mydomain/projecten/project.php?project=1

I thought that

$_SERVER['HTTP_HOST']

would give me http://mydomain.nl, why isn't it doing this?

Foi útil?

Solução

Start your link with http://, https:// or //. $_SERVER['HTTP_HOST'] only contains the host, not the protocol.

Outras dicas

You need to specify protocol that is http://

echo '<a href="http://'.$_SERVER['HTTP_HOST'].'"/projecten/project.php?project=1';

or for secure link use

echo '<a href="https://'.$_SERVER['HTTPS_HOST'].'"/projecten/project.php?project=1';

you can easy see what configuration is used by this scriplet

<?php
    phpinfo();
?>

i thougt what you want is to use $_SERVER["SERVER_NAME"]

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top