Step 6: Configure clean URLs

 

General Information

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 "?q=" as "http://www.example.com/node/83".

The style of URLs using "?q=" 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 Google's 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's 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 the links section below (just above the Comments section of this page) to see if there might be something that addresses your server configuration on a different page.

Before enabling clean URLs in the Drupal configuration screens (see below), 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 DreamHost, BlueHost, HostGator, GoDaddy, 1and1, et al.), you will not be able to modify the httpd.conf file and should use the Drupal .htaccess file instead.

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, .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 "?q=" 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

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". So before trying to enable Clean URLs, make sure this file exists in your Drupal installation.

Drupal 8.x

In Drupal 8, clean URLS are enabled by default and can't be disabled. You will need some form of rewrite module installed on your web server.

Drupal 7.x

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:

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

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.

Drupal 6.x

In Drupal 6, the installer tests for compatibility with Clean URLs as a part of the installation process. If the installer was not able to run the test successfully at install time, you can later follow the instructions below for Drupal 5 to get Clean URLs working. There is one minor difference: Drupal 6 will run the clean URL test automatically when you navigate to the Clean URLs configuration page and will show the results, in place of giving you a link to run the test manually.

Also note that 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.

Drupal 5.x

Here are the steps necessary to enable Clean URLs in Drupal 5:

  1. Go to the Clean URL's (Administer > Site configuration > Clean URLs in Drupal 5) section of the administrative interface.
  2. Look for the paragraph that reads as follows:

    This option makes Drupal emit "clean" URLs (i.e. without ?q= in the URL.) Before enabling clean URLs, you must perform a test to determine if your server is properly configured. If you are able to see this page again after clicking the "Run the clean URL test" link, the test has succeeded and the radio buttons above will be available. If instead you are directed to a "Page not found" error, you will need to change the configuration of your server. The handbook page on Clean URLs has additional troubleshooting information. Run the clean URL test.

  3. Click on the Run the clean URL test link at the end of the above paragraph.
  4. If the test is successful, set Clean URLs to "enabled" and save the configuration. If the test is not successful, use the steps below to fix your server configuration and try again.

Prior to Drupal 5.x

For Drupal versions prior to Drupal 5, there is no automatic Clean URLs test or link. Instead, you can test manually by typing in the Clean URL for your settings page: http://www.example.com/admin/settings (where www.example.com is replaced by your hostname). If this results in seeing the settings page, and no errors, then Clean URLs are safe to enable, and you can do so with the setting on this page. If there is an error, follow the instructions below to configure your server.

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 Drupal-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 'non-clean' form: http://www.example.com/?q=admin/settings for the admin settings page in Drupal 4.x, or http://www.example.com/?q=admin/settings/clean-urls to get to the Drupal 5 or Drupal 6 Clean URLs settings page, or for Drupal 7 you can go to http://www.example.com/?q=admin/config/search/clean-urls. Once there, you should be able to reset to not using Clean URLs.

There are additional instructions for recovering from malfunctioning Clean URLs the Handbook page Unset clean URLs.

Server configuration for Clean URLs

You can read more about other web server requirements

Server configuration for Clean URLs on a dedicated server, with httpd.conf

Enabling clean URLs on a dedicated server involves these steps:

  1. Enable mod_rewrite for Apache. You can talk to your web host or consult the Apache documentation for mod_rewrite to get more information on how to do this. At a minimum, this will involve making sure that mod_rewrite is enabled for your installation of Apache.

    To test if mod_rewrite is available in Apache2, you can type the following at a command prompt, to list all installed Apache modules:

    apache2ctl -M

    On some systems this command may be:

    apachectl -M

    In the output, check to see if the rewrite_module is included in the list of modules.

    If the rewrite module is not in the list, it will have to be either compiled-in or made available as a loadable module. Generally speaking, you can tell Apache to load the module by including

    LoadModule rewrite_module modules/mod_rewrite.so
    AddModule mod_rewrite.c

    in your Apache configuration file (see below for information on the configuration file). Be sure to uncomment AddModule mod_rewrite.c, if it is in your configuration file but has been commented out. The following may work to enable the module without editing any files:

    a2enmod rewrite

    Note that these approaches may not work for all combinations of operating system and Apache server -- consult the Apache documentation that came with your Apache software for the correct syntax.

    Remember to restart Apache for the new configuration to take effect.

  2. The next step is to locate the appropriate Apache configuration file for your site. Depending on your server configuration, the appropriate Apache configuration file could be httpd.conf, a virtual-host-specific file (vhost.conf), a specific site file (e.g. "default"), or apache2.conf. They are usually located in /etc/httpd/conf/etc/apache2, or a sub-directory; if not, try the command:
    find /etc -name httpd*
    or
    find /etc -name apache2*

    to find the file if it is located elsewhere in your file system.

    If you do not have write permissions to these files, and Clean URLs are not working out-of-the-box for you, you may have to ask your systems administrator or hosting provider for help. You may still be able to readthese configuration files to troubleshoot a little however.

  3. The next step is to copy or include the Drupal-specific settings directly into your configuration file. There are instructions here for how to include the Drupal directives in your configuration file. Consult the .htaccess file in Drupal for examples of rules, such as the following for Drupal 6:
    <Directory /var/www/example.com>
      RewriteEngine on
      RewriteBase /
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    </Directory>

    Similar rules for Drupal 7 and 8 are:

      RewriteEngine on
      RewriteBase /
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_URI} !=/favicon.ico
      RewriteRule ^ index.php [L]

    Make sure that you are looking at the .htaccess file for your major version of Drupal (i.e., 7.x, 6.x, 5.x).

Note: If you do not want to put the rewrite rules in your Apache configuration file, you can still simply use the Drupal .htaccess file (as you would if you were on shared hosting). You will need to have the Allow Override directive set in your Apache configuration file (this will allow local .htaccess overrides on your site):

AllowOverride All
AccessFileName .htaccess

Read Behind the scenes with Apache's .htaccess for a thorough review of .htaccess. You may also find it helpful to view samples of Apache 2 AllowOverride directives.

Note Regarding MultiViews: Apache 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, it can cause problems when Drupal's Clean URLs are enabled. Unless you know what you're doing, you should not use MultiViews if you plan to use the Clean URLs feature of Drupal. However, MultiViews is not enabled in a default Apache installation, so it is likely that this note will not apply. Consult the Apache documentation for further information about MultiViews.

Server configuration for Clean URLs on a shared server, with .htaccess

The standard Drupal installation contains a sample .htaccess file which should be sufficient to get Clean URLs running. It is easy to miss copying this file, because of the leading "dot". So before trying to enable Clean URLs, make sure this file exists in your Drupal installation.

To check for this in terminal, use ls -a to make sure the "dot" files are also listed.

If you have this file installed, but Clean URLs still do not work, you can try some of the troubleshooting suggestions below. If you still cannot get Clean URLs to work, contact your hosting provider.

Clean URLs on Windows servers with IIS

Starting from Drupal 7, the package includes a basic web.config file for use with IIS.
See this article for more information and setup instructions.

Fixing problems

Check that .htaccess is even being used

Apache needs to be explicitly told to respect the instructions in your sites .htaccess file. This is off by default, though most hosts will have turned it on. That is what the AllowOverride All directive above does - it makes .htaccess start working.

To check if your host is currently even reading your .htaccess, you can (temporarily) add some garbage string to the file in an attempt to break it. Your site should immediately start returning a "500 Server Error" when you load a page from that directory due to this misconfiguration. (Remove the garbage string immediately.)

If you do this, and your site does not break - then .htaccess is being ignored and you will not be able to use clean URLs until you get support from your hosts, or enable it in httpd.conf as described above. Some hosts allow you to enable this option through their site management control panel, so look there first.

RewriteBase setting

The main configuration option which may need to be changed for your site is the RewriteBase. This can be specified in the Drupal .htaccess file or in the httpd.conf file, depending on where you are putting the Drupal rewrite directives (see above). By default, the RewriteBase setting is commented out of the Drupal .htaccess file, and that works well for many configurations.

If you are having trouble getting Clean URLs to work, you may need to change this setting. 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 could be set to

RewriteBase /mysite

and that might help. In some configurations, setting

RewriteBase /

will allow clean URLs to work.

$base_url

You may need to manually set the $base_url variable in the settings.php file if not already set. It's currently known that servers running FastCGI can run into problems if the $base_url variable is left commented out (see http://bugs.php.net/bug.php?id=19656).

Multi-site

RewriteBase works when your Drupal installation serves only one site, or when all the sites it serves are in the same subdirectory of their domains. For example,

RewriteBase /

will work for the following sites:

http://www.example.com/
http://www.example2.com/
http://www.example3.com/

RewriteBase /mysite

will work for the following sites:

http://www.example.com/mysite
http://www.example2.com/mysite
http://www.example3.com/mysite

However, if your sites are in different subdirectories, RewriteBase will not work. You will need to create a special rule for each subdirectory. For example, your Drupal installation may serve the following sites:

http://www.example.com/
http://www.example.com/mysite

In order to enable clean URLs for both sites, you will need to add

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/mysite/
RewriteRule ^ /mysite/index.php [L]

before the existing rewrite rules.

Location of index.php

For some server configurations, another change to the Drupal .htaccess file may be necessary. Find a line that looks like this, near the end of your Drupal .htaccess file:

  RewriteRule ^ index.php [L]

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. This is necessary on some, but not all server configurations.

Create Even Cleaner URLs with the Path Module

Using Clean URLs will cause Drupal to generate URLs in the form "http://www.example.com/node/83." In order to change the 'node/##' portion of the URL to something more like 'news/june-1st-news' a site will need the Path module enabled. See the Path module handbook page for more information on using the path module.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

Need apache VirtualHost setup for rewrites to work

Just thought that It would be good to mention that you need to have a VirtualHost setup in your apache config.
When I did fresh install of apache on ubuntu server 8 I had to first make a static link to the rewrite.load file

as admin I ran the command
a2enmod rewrite

Had to setup a virtual host for my domain name

NameVirtualHost *:80

<VirtualHost *:80>
ServerName yourdomainname.com
ServerAlias *.yourdomainname.com
DocumentRoot /var/www/drupal6/
</VirtualHost>

restart apache

/etc/init.d/apache2 restart

Litte ontribution

Scenario:
Fedora Core 4
Apache 1.3
Multisite (Many web applications, 4 moodle sites and drupal)
web directory /www/moodle1 - /www/moodle2 - /www/webappx - /www/drupal - etc)

I just added next lines at the server httpd.conf file and it worked

# for drupal, added by achandia
<Directory "/www/drupal">
  AllowOverride All
</Directory>

restart apache
/etc/init.d/httpd restart

I hope this helps.

@ch

Yes, setting up a virtual host makes 'clean URLs' work.

I set a virtual host as follows and now I can have 'Clean URLs' work.
For some reason, the same setup did not work with Drupal-6.17.

<VirtualHost *:80>
    ServerAdmin abc@xxx.org
    DocumentRoot /opt/lampp/htdocs/drupal-6.16
    ServerName drupal.xxx.org
    ErrorLog logs/xxx.org-error_log
    CustomLog logs/xxx.org-access_log common
</VirtualHost>
<Directory "/opt/lampp/htdocs/drupal-6.16">
   RewriteEngine on
   RewriteBase /drupal-6.16
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>

Re: Yes, setting up a virtual host makes 'clean URLs' work.

pinenut> I set a virtual host as follows and now I can have
pinenut> 'Clean URLs' work. For some reason, the same
pinenut> setup did not work with Drupal-6.17.

I've just updated to Drupal-6.17, and configured according to the instructions. It worked for me. I've got two suggestions:

  1. You've got "drupal-6.16" in your DocumentRoot, Directory and and RewriteBase. Have these directories been renamed to drupal-6.17 during your upgrade?
  2. Try moving the </VirtualHost> line to underneath </Directory>, so that the Directory section is embedded in the VirtualHost.

Clean URLs not working Zend Server Community Edition

Hi Friends,

I am using Zend Server Community Edition (Windows Version - Windows 7) and I have set Virtual Host on httpd-vhosts.conf like below

ServerAdmin
DocumentRoot "full/directory/path"
ServerName drupal.local

Options All Includes +Indexes +ExecCGI +FollowSymlinks
Options FollowSymlinks
AllowOverride All
Allow from all

ErrorLog "logs/drupal.local.log"
CustomLog "logs/drupal.local.log" common

I have also set "AllowOverride All" in httpd.conf file.

Still problem exist of Clean URLs.

Details:
Zend Server Community Edition (Windows Version - Windows 7)
Apache 2.2
PHP 5.3

Please consider this as an urgent issue.

Enabling clean urls for Ubuntu 14.04

(1) Run the command a2enmod rewrite on your ubuntu (Command Line Interface) CLI to make sure rewrites are installed.

(2) vi /etc/apache2/apache2.conf

a. Under all the AllowOverride All

(3) In the .htaccess file under /var/www/ if that is your place of drupal installation make sure the Rewritebase / is uncommented and correct. If your drupal installation is **Rewritebase /var/www/drupa**l, then change it to that.

(4) Run command service apache2 restart on your ubuntu CLI and you should be good. * Optional - make sure your root

~Good Luck

clean url on multisite

on a drupal regular multisite clean url will not work without .htaccess in each project root, so make sure to copy also .htaccess

/.htaccess
/anothersite/.htaccess

Hope that helps anybody

Clean URL .htacccess with DreamHost, GODaddy and Bluehost

DreamHost users have to use following code in .htaccess for clean URL

I haven’t test on godaddy and blueshot, but they should work the same

<IfModule mod_rewrite.c>

   RewriteEngine on

   RewriteBase /

   RewriteCond %{REQUEST_FILENAME} !-f

   RewriteCond %{REQUEST_FILENAME} !-d

   RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

</IfModule>

godaddy settings

As a further update on anyone using godaddy:
I have a deluxe hosting with many sites. Using ftp, I edit the .htaccess file for the directory I am loading drupal in. At the bottom, remove the comment symbol to show the following

<IfModule mod_rewrite.c>
   RewriteEngine on
#
# big bunch of comment lines
#
   RewriteBase /
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_URI} !=/favicon.ico
   RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>

The line with favican.ico was there. Even though I am using a subdirectory, I didn't need to change any of the lines. Save and check clean url's. Should work right away.

Same problem D7.12 on shared hosting - fixed

Thanks, this also solved the problem for me.

Just to clarify, this is the .htaccess file in the Drupal root directory.

In the section of code which reads:

 
  # Pass all requests not referring directly to files in the filesystem to
  # index.php. Clean URLs are handled in drupal_environment_initialize().
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^ index.php [L]

.. the last line was changed to:

  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Lucy C

Fixed Clean Urls at Godaddy Settings

After moving my site from an "Economy" to a "Deluxed" Godaddy's account (shared with another site), Clean URLs didn't work as before the moving, after days trying to find the answer I just figured out:

I change the following line in the .htaccess:
(exactly how it comes by default in your drupal installations files):

RewriteRule ^ index.php [L]

so it would now be:

RewriteRule ^ /index.php [L]

(note the slash "/" in front of "index.php [L]"

after that it would look like this:

# Pass all requests not referring directly to files in the filesystem to
# index.php. Clean URLs are handled in drupal_environment_initialize().
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ /index.php [L]

Some systems need index.php and others need /index.php in order to work further than the Drupal front page when Clean Url is not enabled.
I hope it helps
I also noted that: when this line is missing or commented drupal can not change from "Clean URLs"

Works on Bluehost shared hosting for me too

Fixed clean URLs immediately. No probs so far. This is in my subdomain root .htaccess for this particular Drupal install.

Works on Bluehost!

Thank you, I had been trying to find this feature and the above works on Bluehost. If you're unfamiliar about how to get to this file (I had to learn today). cPanel -> File Manager and in the popup, choose your root of your Drupal site and before you hit Go, there's a checkbox to show hidden files. Click that, then on the next page you can edit your .htaccess file and add the code.

Changing to RewriteRule ^(.*)

Changing to RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] in my bluehost site made clean urls start working in my d6 site. With this change, and everything else as default in php.ini, .htaccess and settings.php, the clean urls test page started reporting that the system now supported clean urls.
Thanks so much!

1And1 Solution

For 1And1 with PHP 5, only change needed is:
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
to:
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]

Found solution here: http://geeksandgod.com/forum/drupals-clean-urls

Using Clean URLs and WAMP2

Windows
c:\wamp\bin\apache\Apache2.2.11\conf\httpd.conf
uncomment
#LoadModule rewrite_module modules/mod_rewrite.so
will have
LoadModule rewrite_module modules/mod_rewrite.so

Uniform Server 4.0 (Mona)

This edit is also required in uniserv 4.0.

Edit the file
[drive][path]\Uniform Server\udrive\usr\local\apache2\conf\httpd.conf

Change line 194
#LoadModule rewrite_module modules/mod_rewrite.so
to
LoadModule rewrite_module modules/mod_rewrite.so

See http://wiki.uniformserver.com/index.php/Installing_Drupal_on_4.0-Monafor more tips.

Versions prior to 4 already have the rewrite_module line uncommented.

UBUNTU

I wanted to share my problem with getting clean urls to work in ubuntu. I couldn't find any info on how to do this, but finally I pieced it together and it is actually very simple. Just do the following:

1)enable rewrite module on apache.
a2enmod rewrite
(to disable type a2dismod rewrite)

2)Set directory permission.
You must find the file that sets permission of each directory for apache. In my case it was /etc/apache2/sites-enabled/000-default
edit the page so that the directory that you will be using to serve webpages has "AllowOverride All". My file contains the following:

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

3)Just restart apache and it should be working:
/etc/init.d/apache2 restart

Ubuntu 10.04 LTS + Apache2 +PHP5 + MySql 5.1.41 + Drupal 6.16

I followed Method 2 http://drupal.org/node/134439

You have to enabled the rewrite module(mod_rewrite)

sudo a2enmod rewrite

My Drupal Installation serves one site which is in the subdirectory Drupal6

Hence my site address is http://localhost/drupal6

1st step

With Apache version 2, the httpd.conf has been deprecated (actually mine is empty ), and the new file is located at: /etc/apache2/apache2.conf

So, in the command line type:

sudo  /etc/apache2/apache2.conf

Copy paste following lines in the directory section, if it doesn't exist, just copy paste the lines at the bottom , and save the file.

<Directory /var/www/localhost/drupal6>
AllowOverride All
</Directory>

2nd step

sudo nano etc/apache2/apache2.cnf

Copy paste the following lines and save the file

RewriteLog "/var/log/apache2/rewrite.log"
RewriteLogLevel 3

3rd step

sudo nano /etc/drupal/6/htaccess

Under rewrite rules make sure the following lines exist otherwise copy paste them , make sure to replace /drupal6 in line 4, /drupal6 in line 7 and /drupal6 in line 8 by your site's directory otherwise it won't work. Save changes.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule "(^|/)\." - [F]
RewriteBase /drupal6
RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/drupal6/(.*)$
  RewriteRule ^(.*)$ /drupal6/index.php?q=$1 [L,QSA]
</IfModule>

4th step

Reload apache

sudo /etc/init.d/apache2 reload

5th step

Enable url rewriting at /admin/settings/clean-urls
save changes

 

alaca

 

Easier

Easier way?
https://help.ubuntu.com/community/Drupal

sudo gedit /etc/apache2/sites-available/default

Find every occurrence of "AllowOverride none" and replace with "AllowOverride All" then save and restart your server.

sudo /etc/init.d/apache2 restart
or
sudo service apache2 restart

Also, you need to change the RewriteBase line in the htaccess file in your drupal folder in order to get clean urls working (Ubuntu 10.04).

Example, my install is /var/www/html/

cd /var/www/html
sudo gedit .htaccess

# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
RewriteBase /html

Seems to work for me.

clean urls

this work for me in the .htaccess file
place full website url in RewriteRule

example: RewriteRule ^(.*)$http://www.yoursite.com/drupalfolder/index.php?q=$1 [L,QSA]

RewriteBase /

# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ http://www.yoursite.com/drupalfolder/index.php?q=$1 [L,QSA]