Attempt a better base_url auto-detection
#3253