Dville Posted July 25, 2006 Share Posted July 25, 2006 I searched both google and here for this, and couldn't find anything. But maybe the standard term for it isn't base url.I have a config.php where i put the mysql database variables, along with the $admin variable, which tells the script what username in the users table has admin rights.What I'm wanting to add to this config.php is a 'base url' variable of sorts, that will hold where the script is running from.So if the user installs it to /digg or /was instead of / the rest of the url/links will be pointing in the right spot.A - how do i setup this variableB - how do i use it in the scriptfor example, if one of my lines look like this[code]<?php echo "/digg/comment.php?appid=$id"; ?>[/code]where in the config, /digg would be the 'base url'. how would i change the link to work(syntax wise)thanks in advanced for anyone who can help me with this Link to comment https://forums.phpfreaks.com/topic/15599-base-url/ Share on other sites More sharing options...
obsidian Posted July 25, 2006 Share Posted July 25, 2006 typically, when i need to do something like this, i just set a $path variable with my application root folder in relation to the server root in my include file. that way, whenever i call a link or action or whatever, i simply need to append $path to the front:[code]<?php// in my include file$path = "/myApp";// then, in my application links:echo "<a href=\"$path/index.php\">Home</a>\n";?>[/code]hope this helps Link to comment https://forums.phpfreaks.com/topic/15599-base-url/#findComment-63454 Share on other sites More sharing options...
hackerkts Posted July 25, 2006 Share Posted July 25, 2006 Hope I got it right, try this[quote]$baseurl = 'http://'.$_SERVER['HTTP_HOST'].substr($_SERVER['SCRIPT_NAME'],0,strlen($_SERVER['SCRIPT_NAME'])-[b]12[/b]);[/quote] Link to comment https://forums.phpfreaks.com/topic/15599-base-url/#findComment-63458 Share on other sites More sharing options...
Dville Posted July 25, 2006 Author Share Posted July 25, 2006 cool, thanks obs. that wasnt too bad, i was thinking i had to use something like _BASE which i've no exp with.thanks again Link to comment https://forums.phpfreaks.com/topic/15599-base-url/#findComment-63473 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.