Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 

In Drupal 7, there was a 'clean_url' configuration variable, and a admin/config/search/clean-urls form for configuring it. This has been removed from Drupal 8. Instead, if you access a Drupal page whose path is 'some/path' as http://example.com/some/path, then Drupal detects this as a clean URL and outputs all links from that page as clean URLs. On the other hand, if your site is on a server where clean URLs do not work, you can access that page as http://example.com/index.php/some/path, and when you do, Drupal outputs all links from that page as "dirty" URLs (i.e., with the "index.php" included).

If you have publicly exposed URLs that include old-style dirty URLs, using ?q=, it is recommended to adjust your URLs to the new format ASAP. To provide automatic forwarding for ?q=-style URLs to avoid SEO breaks, install the Legacy Redirect module.

There is some in-progress work for handling upgrade issues and edge cases in #1546082: Follow-up to variable_get('clean_url') removal.

As a result of this change, modules that display label prefixes in front of form input elements containing Drupal paths can be simplified as follows.

Drupal 7:

function path_admin_form($form, &$form_state, ...) {
  $form['source'] = array(
    '#type' => 'textfield', 
    '#title' => t('Existing system path'), 
    '#description' => t('Specify the existing path you wish to alias. For example: node/28, forum/1, taxonomy/term/1.'), 
    '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='), 
  );
  ...
}

Drupal 8:

function path_admin_form($form, &$form_state, ...) {
  $form['source'] = array(
    '#type' => 'textfield', 
    '#title' => t('Existing system path'), 
    '#description' => t('Specify the existing path you wish to alias. For example: node/28, forum/1, taxonomy/term/1.'), 
    '#field_prefix' => url(NULL, array('absolute' => TRUE)),
  );
  ...
}
Impacts: 
Site builders, administrators, editors
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done

Comments

holtzermann17’s picture

#documentation

This is what I had in my httpd.conf for D7 (getting clean URLs to work).

<Directory /opt/local/apache2/htdocs/drupal>
   RewriteEngine on
   RewriteBase /
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ /drupal/index.php?q=$1 [L,QSA]
</Directory>

This is what I had to put into my httpd.conf to get "not dirty" URLs to work in D8.

<Directory /opt/local/apache2/htdocs/d8>
   RewriteEngine on
   RewriteBase /
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ /d8/index.php/$1 [L,QSA]
</Directory>
Dave Kopecek’s picture

Yes!! Thank you. #1 worked for me. I just used:

   RewriteRule ^(.*)$ /index.php/$1 [L,QSA]
dcrocks’s picture

If you add RewriteBase /some/path
it seems to work just as well. Given the number of issues that have been opened and quickly closed the last year because someone expected the same behavior as D7 on clean url's, it would be nice if install put out a warning when a site is not configured for clean url's.

David Rocks

YesCT’s picture

See issue https://drupal.org/node/2094985 "Drupal 8 install does not warn if Clean Urls are not supported"