Jump to content

Archived

This topic is now archived and is closed to further replies.

Dville

Base URL

Recommended Posts

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 variable
B - how do i use it in the script

for 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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.