When I run drush user-login username
, drush prints a url like http://default/user/reset/1/32323933...
. How do I replace default with the actual website name?
5 Answers
You can use option --url
:
-l <http://example.com:8888>, URI of the drupal site to use (only needed in multisite environments or when running on an alternate port).
--uri=<http://example.com:8888>
$ drush uli -l yoursite.dev
Or create a record in your aliases.drushrc.php file:
$aliases['yoursite-dev'] = array(
'root' => '/vhosts/yoursite.dev',
'uri' => 'yoursite.dev',
);
Now you have an alias @yoursite-dev
and can use it:
$ drush use @yoursite-dev
$ drush uli
Update:
Now I prefer to create sites/default/drushrc.php
file for each Drupal folder:
<?php
$options['l'] = 'http://yoursite.dev';
$options['r'] = '/vhosts/yoursite.dev';
More info about drushrc.php
: https://raw.githubusercontent.com/drush-ops/drush/8.x/examples/example.drushrc.php
I used this command for login into my local site:
drush uli --uri=http://your_local_url
You can set the uri in a drush site alias file to avoid getting http://default at the beginning of your password reset links.
ie. drush/sites/example.sites.yml
live:
host: server.example.com
user: user
ssh: '-p 22'
root: /home/user/public_html/docroot
uri: 'http://example.com'
test:
host: server2.example.net
user: user2
ssh: '-p 22'
root: /home/user2/public_html/docroot
uri: 'http://test.example.net'
dev:
host: localhost
user: docker
root: /var/www/docroot
uri: 'http://example.dev.example.com'
Then use the Drush site alias in the command for the password reset link:
drush @example.dev uli
The example after the @ symbol in the Drush site alias comes from the first part of the Drush site alias filename. The second part comes from the site entry in the file.
You could also export the environment variable DRUSH_OPTIONS_URI.
export DRUSH_OPTIONS_URI=http://example.com
I work with lando and I threw together the following function:
duli() {
sitename=$(lando info|grep -E https|tail -n1|cut -d \' -f2)
lando drush uli -l $sitename;
}
site_name
is used to save the name of the site in Drupal 6, the commanddrush vget site_name
would give out the same, so probablydrush vset site_name WHATEVER_NAME_TO_SET
should do the work...