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
https://forums.phpfreaks.com/topic/15599-base-url/
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
https://forums.phpfreaks.com/topic/15599-base-url/#findComment-63454
Share on other sites

Archived

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

×
×
  • 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.