tags:

views:

30

answers:

2

Hello, Im working on a Drupal installation where the setup in my local testing server is different from online server.

On my local server drupal is installed in /var/www/my_drupal and the base_path is set to /mydrupal but on the online server its installed on the root of the site, usually /public_html/

So my problem is I wanted to set a base_path and base_url variable depending on the server i am on. Where do i place my codes so that it's accessible site-wide.?

Thanks!

A: 

I would set it in your settings file in sites/default/settings.php just use an if statement to detect whether it is the local or live site ur on and then set the variables accordingly.

if ($_SERVER['SERVER_NAME'] == 'localhost') { // the script is running on the local } else { // it is on remote }

geoffs3310
brilliant. i forgot about that file.. i was looking at hook_boot and hook_init but im not really sure how to write a module that will listen to this events.Edit:I assume this would be available site-wide>?
r2b2
+1  A: 

Luckily Drupal already has taken care of this for you

See the api site for a full listing

Of particular interest to you should be:

$base_path developer/globals.php The base path of the drupal installation. At least will default to /.
$base_url developer/globals.php The base URL of the drupal installation.
wiifm