The global $base_url variable begins with http:///.
For example, the following command will display "http:///example.com":
drush eval "global \$base_url; drush_print\(\$base_url\);"
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | drush_base_url_591814.patch | 670 bytes | srhaber |
| #4 | 591814.patch | 1.11 KB | owen barton |
Comments
Comment #1
srhaber commentedI should mention that I run Drush on a multisite environment, so I usually pass in the -l option. I see the three slashes when I run this command:
drush -l example.com eval "global \$base_url; drush_print\(\$base_url\);"This displays http:///example.com.
However, I just saw Moshe's comment about always including http:// in the -l option here: http://drupal.org/node/523194#comment-2098778
Sure enough, when I use this below command then $base_url displays correctly:
drush -l http://example.com eval "global \$base_url; drush_print\(\$base_url\);"This displays http://example.com.
Comment #2
srhaber commentedI added some logic to my drushrc.php to work around this. However, I feel drush should be able to support taking host names without the http:// prefix. Changing this from a bug report to feature request.
Comment #3
moshe weitzman commentedIt doesn't allow that, because $base_url in drupal doesn't allow that. it might be more helpful to rename --uri to --base-url. Comments?
Comment #4
owen barton commentedI don't have a problem with allowing the "http://" to be omitted, I don't think forcing it to be there adds any value, and we are already adding one implicitly for URIs guessed from the site directory name.
What about the attached patch? You can still pass http:// if you prefer (or https:// or any other protocol if working on something really weird!).
Comment #5
srhaber commentedI agree the "http://" should be added by default if it's not included. Attached is my patch which has same effect as #4.
We should probably rename this thread to "Make http:// prefix optional for --url option"?
Comment #6
moshe weitzman commentedCommitted #5. Thanks all.