Jump to content

Base URL


Dville

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.