How do I Enable Clean URLs for Drupal 8?

How do I Enable Clean URLs for Drupal 8?

A query string is text in a URL preceded with a “?”. Drupal’s “clean URLs” rewrite query strings into human-readable text. Query strings get in the way of search engines. Google’s not bad at understanding URLs with query strings, but it does not always get it right. Make sure your URLs don’t contain query strings. Clean URLs are installed on your Drupal 8 site by default and cannot be turned off. But, it is possible that the proper software isn’t installed on your server, so it’s worth checking, just to be sure.

How do I tell if clean URLs are enabled in Drupal?

  1. Open an Incognito window and go to the homepage of your website.
  2. Click on a piece of content on your site. You need to navigate to an actual blog post or node, not the home page.
  3. Look for “?q=” in the URL.
  4. If the URL looks like this: http://drupal8.dev/my-blog-post- title then clean URLs are enabled and you can skip to the next section of the book.
  5. If the URL looks something like this: http://drupal8.dev/?q=node/4 then clean URLs are not enabled. Continue in this section.

The URL on top is “clean”. The URL on the bottom is “dirty”.

How do I fix URLs if they are dirty?

Here’s the good news: there’s nothing you can do yourself to fix your dirty URLs. You need to get in touch with your developer or hosting company and say this magic sentence: “It looks like my URLs are dirty because I’m seeing “?q=” in the paths. Would you please enable mod_rewrite for Apache on my server?” You can point them to this URL: https://www.drupal.org/getting-started/clean- urls#dedicated which explains things in more detail, but the magic sentence above will normally get the job done. Once mod_rewrite is turned on, you should use an incognito window to test it again.