How to address "failed Drupal Clean url Test"

Drupal makes room for testing clean URLs to see if your website can run clean urls or search engine urls. This will address the issues associated with Drupal urls which by default will look like this, "/?q=node/4". This type of URL can be hard to read, hard to remember and may not be search engine friendly.

In your Drupal site's admin area, go to Configuration

Click the "Run the clean URL test"

General Information About Drupal URL Settings

By default, Drupal uses and generates URLs for your site's pages that look like http://www.example.com/?q=node/83. With so-called clean URLs this would be displayed without the ? like this: http://www.example.com/node/83

You will also want to read:

A Basic Guide to Drupal Website Managemen

Drupal Website Maintenance tutorial

The style of URLs using "?" can be hard to read, and may even prevent some search engines from indexing all the pages of your site. Research suggests this may not be as big of a problem for major search engines as it once was; however, it is worth noting the recommendation from webmaster guidelines stating

"If you decide to use dynamic pages (i.e. the URL contains a character), be aware that not every search engine spider crawls dynamic pages as well as static pages. It helps to keep the parameters short and the number of them few.

If you are unhappy with the default URLs in Drupal, you may be able to tell Drupal to use clean URLs eliminating the "?q" in your site URLs, and this page explains how to do it. The instructions below are largely applicable only for the most common server setup, which is an Apache web server running on some flavor of Unix/Linux, with the "mod_rewrite Apache module" (this link is for Apache 2.4) configured and mod_rewrite enabled in httpd.conf configuration file. If you are running Drupal on a different type of server, check to see if there might be something that addresses your server configuration differently.

Before enabling clean URLs in the Drupal configuration screens you may need to prepare your server for clean URLs to work. There are two ways to prepare your server for clean URLs to work in Drupal. If you have complete control of your server, for example: You run your own server; are installing a development site on your personal computer; or you have a dedicated server hosting account, then you should enable clean URLs in the httpd.conf file for better performance and security. However, if you have a shared hosting account (at Todhost, et al.), you will not be able to modify the httpd.conf file and should use the Drupal .htaccess file instead.

You will also want to read:

Drupal Website Security Tutorial

Drupal configuration tutorial



Clean-Urls Test - False Negatives

On some setups the Clean Urls test gives a false negative result. If you can visit Clean Url links like http://example.com/user/login and Drupal returns the user login page, then .htaccess and mod_rewrite are working. Visiting the Clean Urls admin page directly at http://example.com/admin/config/search/clean-urls, should give you a checkbox that lets you enable Clean Urls (note the lack of ? in the URL). See http://drupal.org/node/1178850. Note: If Clean Urls like http://example.com/user/login. stops working (switching hosts) you can visit the same page by changing the URL to look like: http://www.example.com/?q=user/login.

Enabling Clean URLs in Drupal

The standard Drupal installation contains a sample .htaccess file that supports Clean URLs, so make sure this file exists before enabling Clean URLs. Before copying this file make sure there is a dot , in the .htaccess file's name. It is very important to how Apache works.

In Drupal 7, the installer tests for compatibility with Clean URLs as a part of the installation process. If the environment is tested as compatible with Clean URLs, it will be enabled as part of the installation process and no further action is required to enable Clean URLs.

If you need to enable Clean URLs post installation, Drupal will run the clean URL test automatically when you navigate to the Clean URLs configuration page (Administer > Configuration Search and metadata; Clean URLs), show the results, and allow you to save configuration

You can enable or disable it at a later time by following these steps:

Navigate to the Clean URLs configuration page (Administer > Configuration Search and metadata; Clean URLs)
Wait for the automated Clean URLs test to run.
Check or uncheck the Enable clean URLs checkbox
Click "Save configuration&quot

Even if Clean URLs are successfully enabled at install-time, if you have a dedicated server you may still want to follow the steps (below) to enable the more efficient httpd.conf rewrite method for clean URLs. If you choose to do that, you might want to turn off Clean URLs while you are working on the server.

You will also want to read:

How to Speed Up Your Drupal Website

Installing a new Drupal website

Error recovery

Enabling "Clean URLs when your server is not properly configured (i.e. if the Clean URLs tests described above fail) can make it difficult to navigate back to administration pages to undo your mistake, because all the Dru pal-generated menus and links will have URLs that do not work. If you find yourself in this situation, you can return to the administrative settings page by typing in the URL in the clean form. Once there, you should be able to reset to not using Clean URLs.

Summary of How to address failed Drupal Clean url Test

This tutorial will show you what to do if the test fails. You will have to take the following steps:

Step #1. Ensure your .htaccess file is available and working

This step assume that you are using an Apache server.

htaccess is a file on Apache servers which sets important configurations for the directory it lives in and the directories below it.

The .htaccess file, which is included in Drupal core, defaults to clean URLs. So if your clean URLs are not working, first ensure that you have a .htaccess file in your site&amp

Note: Since the file name begins with a dot (.) it is hidden on most file managers and it is easy to omit the file when copying files to a new folder: htaccess.

If your .htaccess file exists, then ensure that it is working by adding a line of gibberish into the file and reloading your web page. It should immediately return a "500 server error". If an error is returned then the .htaccess file is working. Remove the line of gibberish that you just added.

If your .htaccess file exists, it's also worth comparing it to the default Drupal .htaccess file. Some hosting companies will use their own version of .htaccess

If your site does not break, then the .htaccess file is not being used and you will not be able to use clean URLs until you either enable it in the httpd.conf file or work with your web host to have it enabled in your httpd.conf file. Sometimes you may be able to do this from the host's control panel.

The httpd.conf file is another Apache configuration file, but this file is found in the apache/conf directory (Acquia DevDesktop) or the conf/apache directory (MAMP) on your Apache server, not in the Drupal installation files.

#2. Check the RewriteBase setting

If clean URLs are still not working, you may need to change the RewriteBase configuration. First, check the DocumentRoot setting in your httpd.conf file: rewritebase

You are trying to find out if DocumentRoot accurately reflects the location of your site.

f DocumentRoot is set to /var/www/ (i.e., /var/www/index.html is what is displayed when you browse to your site: http://www.example.com/) and your Drupal installation is installed in the subdirectory /var/www/mysite/, then the RewriteBase directive in your .htaccess file should be set to:

RewriteBase /mysite

In some configurations, setting

RewriteBase will allow clean URLs. By default the RewriteBase directive is commented out. To uncomment the line, remove the leading hash sign (#) from the line.

#3. Check $base_url setting

You may need to manually uncomment the $base_url setting in your settings.php file. The settings.php file is found in the sites/default directory in the root of your Drupal installation. There are several examples in the file, one of which should match your configuration.

This problem often occurs if your web host is using FastCGI. Check with your web host as to whether or not FastCGI is implemented on your server.

Step #4. Location of index.php

It may be necessary to make another change to the Drupal .htaccess file on some, but not all servers. Scroll to the bottom of your .htaccess file and locate a line that looks like this:

RewriteRule ^ index.php [L]</p

You may need to replace index.php with the URL path to your Drupal installation's index.php file (only the part after the base URL).

For instance, if your site's home page URL is http://example.com/subdir/, you might need to use /subdir/index.php instead of index.php.

If your site's home page URL is http://example.com/, you might need to use /index.php instead of index.php.

Order Web Hosting With Todhost

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Speed Up Your Drupal Website

Drupal is one the top Content Management Systems used for web designing today. Like every other...

Installing a new Drupal website

This article takes you through how to install or set up a Drupal website on the internet.Step 1:...

Drupal configuration tutorial

To configure basic settings for your Drupal website, you first need to login to your Drupal...

Drupal Website Maintenance tutorial

Managing your Drupal website involves performing a lot of tasks which include securing your...

Drupal Website Security Tutorial

Drupal is increasingly gaining some popularity popularity and at the same time it is also...