Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$_SERVER['DOCUMENT_ROOT'] path not working in my html link

Tags:

php

I am getting the expected return with $_SERVER['DOCUMENT_ROOT'], but when i click the link, the string the constant contains is just appending to the web address already there.

For instance i have :

define("ROOT_PATH",$_SERVER["DOCUMENT_ROOT"].'/webroot/mysite/');

then later a link (intended for the root of my site)

$hud .= '<a href="'.ROOT_PATH.'" class="nav_links">Home</a>';

I click the link it gives me this error:

The requested URL /mysite/home/content/39/11607339/html/mysite/includes was not found on this server.

Can someone tell me why it is just appending to the url rather than normal behavior which is just go to that file?

like image 987
Draaken Avatar asked Jul 12 '26 21:07

Draaken


1 Answers

try $_SERVER['HTTP_HOST'] instead of $_SERVER['DOCUMENT_ROOT'] in define function.

like image 65
Sachin Vairagi Avatar answered Jul 15 '26 09:07

Sachin Vairagi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!