You are here:  » Print Base Url

Support Forum



Print Base Url

Submitted by philstone on Thu, 2007-04-05 22:07 in

Hi Dave

Loving the script still!! Thanks so much. I run the script on a few sites and need a hand with something. I want to print the
http://www.mysite.com on a page on the site so that the text is automatically included in a page, how would i do this?

Regards

Phil

ps. when i try <?php print $config_baseHREF?> all that appears is "/"

Submitted by support on Fri, 2007-04-06 08:32

Hi Phil,

To get the URL of the current page you need to use the PHP superglobal $_SERVER["HTTP_HOST"]. You can also use it in conjuction with $_SERVER["REQUEST_URI"] to get the full path to the current script. Try this example to work out what you need:

<?php
  
print "http://".$_SERVER["HTTP_HOST"];
  print 
"<br />";
  print 
"http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
?>

Hope this helps!
Cheers,
David.

Submitted by PipSqueak on Wed, 2007-06-20 19:50

Hi

Your two codes retrieve the domain.com and the page url itself. How do you retrieve the url to the folder where the scripts are located. http://www.domain.com/price_tapestry_script_here/

Submitted by support on Wed, 2007-06-20 20:03

Hi,

Within the Price Tapestry code, I would use the following:

<?php
  
print "http://".$_SERVER["HTTP_HOST"].$config_baseHREF;
?>

That should do the trick!

Cheers,
David.