I have a php-project which is uploaded to a website, my index.php is located at the root of my project which is made like this: http://www.website.com/projectroot . Is there any way to get the link of my projectroot in php from any subdirectory or phpscript? If http://website.com would be my project root, it should return website.com.
Asked
Active
Viewed 134 times
4 Answers
0
I'm not entirley sure what you're asking for, but most people use
$_SERVER["DOCUMENT_ROOT"]
If this isn't what you're after, then you may be better off creating a subdomain or vhost in your httpd file.

Nicholas Mordecai
- 859
- 2
- 12
- 33
0
You can use the global variable in php: $_SERVER['SERVER_NAME']
.
Example how you can use that:
<a href = "<?php echo $_SERVER['SERVER_NAME']; ?>"> Link to Main Site</a>

Sourabh Kumar Sharma
- 2,864
- 3
- 25
- 33