How to fix clean URL issue in Drupal 7

As we know that drupal is content management software and by default it creates URLs that look like query string i.e. "/?q=node/1". This kind of URLs are not search engine friendly and not easy to understandable by google crawler.

So, Drupal 7 provides a core feature i.e. clean url for resolving this issue. But for implementation of this feature, we need to enable it from backend for checking compatability of our site for making urls clean. It works with server configurations in .htaccess file.

Follow these step for enabling clean URL :

  • Login to Drupal Admin
  • Go to Configuration > Clean URLs
  • Checked "Enable clean URLs" and save configuration

If you have got success message, that great. Your clean url is working fine and good to go for further development process of your website.

If you have got error message i.e. The clean URL test failed, you need to follow these steps to resolve the clean url issue.

Step 1: Verify .htaccess file is working

Here, we are assuming that you have hosted your site on apache server .

.htaccess is apache server's configuration file which sets rules and conditions for the directory it lives in and the directories below it. You can easily find this .htaccess file at root directory of Drupal site setup with default configurations according to drupal site.

If you are not having htaccess file at root directory of drupal site, you can create new file but ensure that file name begins with a dot (.) it is hidden on most file managers.

Step 2: Configure RewriteBase

If still your clean url is not working, you must have to check RewriteBase must set to your site root directory in htaccess file.

RewriteBase /mysite

OR

RewriteBase /

This will allow clean URLs. If you have find leading hash sign (#) to RewriteBase directive, get it uncommented. To uncomment the line, remove the leading hash sign from the line.

Step 3: Verify Base URL

If still clean url is not working, you can verify base url in settings.php file. You can found this file in sites/default directory in the root of your Drupal site. This file include several example of configuration like base url. You can uncomment and updated configurations as per your requirement.

Here you are ready to go for resolving clean url issue. After making these changes in configurations, you can enable clean url option from admin panel.