Drupal admin: beware the double slash

Submitted by Frederic Marand on

Sometimes, a double slash appears in your Drupal URLs. This is an error both common and simple to fix. Here's how.

The problem: you're discovering Drupal and setting up your first site, and soon enough you notice that URLs look like:

http://www.example.com/drupal//?q=somepath

Now, you know that Drupal allows you to set up rewritten paths good for SEO, but before getting to that, you need normal urls like these instead of the double slash ones :

http://www.example.com/drupal/?q=somepath

The answer lies in {drupal}/site/default/settings.php. Open it in your favorite text editor and look for the line defining $base_url. It is probably looking like:

$base_url = 'http://www.example.com/drupal/' ;

because you know URLs pointing to directories must have a trailing path... However, look a few lines above, and you'll see the warning:

  /**
   * Base URL:
   *
   * The URL of your website's main page. It is not allowed to have
   * a trailing slash; Drupal will add it for you.
   */

$base_url is NOT an URL ! Instead, it is the base used by Drupal to build URLs. So now you know the fix: remove the trailing slash, save, upload settings.php. The pair of slashes is gone. Issue fixed.

Tagged for , .

UPDATE 2005/09/26 : There is now an issue on Drupal.org about this setting.