Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Enable Clean URLs

Parent Feed: 

easy enable clean URLs for seo

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 doesn’t always get it right. The best practice is to 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 server your site is on hasn't been properly configured, so it’s worth checking to be sure.

Complete Drupal.org documentation on Clean URLs can be found here.
 

How to tell if clean URLs are enabled

  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.clean urls vs unclean urls
    1. If the URL looks like this: https://drupal8.dev/my-blog-post-title then clean URLs are enabled and you can skip to the next section of this guide.
       
    2. If the URL looks something like this: https://drupal8.dev/?q=node/4 then clean URLs are not enabled. Continue in this section.
       

How to fix your 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 the URLs again.

Did you like this walkthrough? Please tell your friends about it!

facebook icon twitter social icon linkedin social icon

Author: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web