I apologize if this has been asked and answered - I searched a few minutes but did not find anything...so here goes. My development team uses a virtual-machine (VMware) for development. The IP address of the guest OS is always dynamic AND not registered to any DNS; therefore I can enter neither a hostname or IP address for $base_url. I need to configure Drupal to use whatever IP address has been assigned at the time.

By commenting out $base_url the links on pages e.g. admin point to valid resources. THE PROBLEM is with form-submit URLs. Links look like http://192.168.93.128:8080/~eastonr/index.php, whereas submit URLs look like http://192.168.93.128:8080/index.php - which happens to be an invalid URL.

Is there a (better) way to achieve dynamic $base_url? Initially I tried setting it to $SERVER_ADDR but that returned http:///. Any help is greatly appreciated!

Comments

javanaut’s picture

What web server are you using?

In general, I would think that a base_url of:

$base_url = 'http://'.$_SERVER['SERVER_ADDR'].'/~eastonr';

should work.

I forget the setting name, but there's a setting in php.ini that exposes all of the $_SERVER[] settings as independent variables.

Rjae Easton’s picture

[Apache 2]

i meant to say also that the '~/eastonr' portion of the url needs to be dynamic as well. it could very well be that i fat-fingered the $_SERVER testing. i will retry that approach.

if you have a sec to suggest handling that portion of the url - would save me some time.

thanks again.

Rjae Easton’s picture

the IP address + port can be dynamically set using this approach - i just finished verifying that. i'll use the Ant build to set the '/~user' part of the request uri - although some regex could complete the solution.

thanks again.

sepeck’s picture

Have you seen this?
http://drupal.org/node/6554

It may help you out.

-sp
---------
Test site...always start with a test site.

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

javanaut’s picture

I wonder if that should be the default base_url.