Reputation: 489
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.
Upvotes: 0
Views: 138
Reputation: 613
<?php
echo "Your Website Root : " . $_SERVER['SERVER_NAME'];
?>
Upvotes: 0
Reputation: 2807
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>
Upvotes: 0
Reputation: 879
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.
Upvotes: 0