Clean URLs
By default, Drupal passes path arguments to itself via its internally generated URLs. This results in URLs that look like the following: "http://www.example.com/?q=node/83." This can make URLs hard to read and it also stops many search engines, like Google, from indexing the pages with these URLs.
You can tell Drupal to use "clean URLs", eliminating the "?q=" in internal URLs. Note that this works only for Apache servers which have the LoadModule rewrite_module configured and mod_rewrite enabled in httpd.conf configuration file.
There are two ways to enable URL rewrites in Apache. If there is complete control of the Apache webserver clean URLs should be enabled in the httpd.conf as this has better performance and security [http://www.serverwatch.com/tutorials/article.php/3436911].
Warning. Enabling "Clean URLs" if your server is not properly configured can make it difficult to navigate back to administration pages to undo your mistake. If you find yourself in this situation, you can return to the administrative settings page by typing in the URL in the 'non-clean' form: http://www.example.com/?q=admin/settings.
Enabling clean URLs involves three steps:
LoadModule rewrite_module modules/mod_rewrite.so AddModule mod_rewrite.c
in your Apache configuration file. Be sure to uncomment AddModule mod_rewrite.c. Note that this may not be the case for all distributions of *nix operating systems. Consult your distribution's documentation that came packaged with your Apache software. We also recommend disabling multiviews in Apache as they conflict with clean URLs.
find /etc -name httpdto find the file if it is located else where in your Unix system. The main configuration option which may need to be changed for your site is the RewriteBase. For example, if your Apache DocumentRoot is /var/www/ (i.e., /var/www/index.html is what is displayed when you point your browser at http://www.example.com/) and your Drupal installation is installed in the subdirectory /var/www/mysite/, then the RewriteBase should be set to /mysite. In some configurations setting
RewriteBase /will allow mod rewrite to work.
If you don't use the .htaccess that comes with Drupal you'll need to add some rewrite rules into your apache directory directive. Consult the .htaccess file in Drupal for examples of rules.
<Directory /var/www/example.com> RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] </Directory>
You will also need to set the Allow Override settings in httpd.conf so that local .htaccess commands will be run for you site. If you are changing the .htaccess file in the Drupal distribution you want to set it to
AllowOverride Allto ensure rewrites are enabled. Read "Behind the scenes with Apache's .htacces [http://brainstormsandraves.com/archives/2005/10/09/htaccess/] for a thorough review of .htaccess. Here are samples of Apache 2 directives [http://httpd.apache.org/docs/2.0/mod/core.html#allowoverride].
Note: The standard Drupal installation contains a sample .htaccess file which supports clean URLs. It is easy to miss copying this file, because of the leading "dot".
Note Regarding MultiViews: The Apache webserver supports a feature called "MultiViews" (more generally: "Content Negotiation"), which allows navigation to your pages without the need for file extensions. For instance, if you had a file called "evaluation.txt", a MultiViews-enabled site could access this file with the URL "example.com/evaluation". While MultiViews can be a handy feature when used knowingly, they can cause problems when Drupal's Clean URLs are enabled. Unless you know what you're doing, you should consider disabling MultiViews if you plan to use the clean URLs feature of Drupal. Be aware that there's a good chance that MultiViews is already disabled, however; it's not enabled in a default Apache installation. Consult the Apache documentation for further information about MultiViews [http://httpd.apache.org/docs/mod/core.html#options].