Last updated March 28, 2014. Created by jbrauer on January 9, 2005.
Edited by authentictech, glass.dimly, rpayanm, craig.norris. Log in to edit this page.

By default, Drupal uses and generates URLs for your site's pages that look like "http://www.example.com/?q=node/83." This style of URLs can be hard to read, and can 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 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 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), 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)
  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. 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 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 read these 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:
    <Directory /var/www/example.com>
       RewriteEngine on
       RewriteBase /
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    </Directory>

    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.

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.

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.

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

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

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

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>

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.

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.

I get the message a2enmod: command not found and
LoadModule: command not found

The server is running on centOS5

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

I was having an issue with multisite. I'm trying to convert about a dozen sites from static to Drupal and couldn't get this to work until I found this post. Awesome.

Gary Johnson
E-Renter.com
Tenant Screening Services

Thanks !!!
Helps me a lot !!!
Hoop !!! Not yet, same problem with Amazon AMI Cloud...

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>

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.

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

Thanks, it works for me on greengeeks vps :)

Khurram Fraz

That "little" detail save my day.
Thanks!

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"

I just set up a D7 site on a greengeeks vps.
I could not get clean urls to work at all. This addition to the .htaccess file did the trick.
Interestingly enough, I had no problem on the same server with clean urls on 2 D6 sites that I was running there.

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.

hello I'm very interested by your post on the clean URL. As I use bluehost made ​​to host my drupal site that is already installed, but I do not have access to the Cpanel because he (the hosting) belongs to my brother who is in another country, he just set up the site and give me an ftp account. is it possible to have access to htaccess in my FTP account assigned to me for changes or it must do so then it is he who has access to Cpanel.Merci!

I think you need to access the .htaccess through the cPanel because it's a hidden file (you can't see it through ftp). Can you get your brother to give you the user name and password to access Bluehost?

it is impossible to do it by FTP access the htaccess necessarily false, as explained above I could thank you Acctiva mine.

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!

To turn on clean URL's on Mac OS X 10.5.6:

Add
AccessFileName .htaccess
to /private/etc/apache2/httpd.conf

Then dependant on where you have installed drupal either:

If you've installed it in /Library/WebServer/Documents
In /private/etc/apache2/httpd.conf change the AllowOverride directive to
AllowOverride All
within the <Directory "/Library/WebServer/Documents">  block.

If you've installed it in /Users/<username>/Sites:
In private/etc/apache2/users/.conf change the AllowOverride directive to
AllowOverride All
within the <Directory "/Users/<username>/Sites"> block (it's likely this will be the only block in this file).

Finally in the .htaccess file in the drupal directory uncomment the line
#RewriteBase /drupal
and change the /drupal to what ever is appropriate for your install

Good luck!

for the last step. this worked for me
RewriteBase /~[username]/ouroakland/htdocs

but this did not:
RewriteBase /Users/[username]/Sites/ouroakland

the leading slash is required.

... but what finally worked for me was:

httpd.conf (mine is at /opt/local/apache2/conf since I'm using a MacPorts installation)

DocumentRoot "/Users/elisevanlooij/Sites"
<Directory "/Users/elisevanlooij/Sites">

~/Sites/Drupal6/.htaccess (I also have a Drupal5 install in Sites)

RewriteBase /~elisevanlooij/Drupal6

Thank you Dilby for taking the time to write out these instructions for your fellow 10.5 users. I'm really happy to finally have this working.

Thank you so much your and dilby's comments finally made things clear for me, fixed my problem, and allowed me to turn on Clean URLs.

All I needed to get CleanURLs (Drupal 6.17) going on my Snow Leopard (PHP5.3) setup was:

In /etc/apache2/httpd.conf change the AllowOverride directive from None (default) to All :
AllowOverride All

And in the .htaccess file in the drupal directory uncomment the line
#RewriteBase / <== whatever is appropriate for your setup

Hope this might help someone else.

Hi,

I have the same OSX version as you do, and Drupal 6.1.9. I did exactly as you instructed, but it did not work. I edited httpd.conf, .htaccess, and restarted apachectl. Can you help?

Thanks

Perfect, this is exactly what I needed. I tried everything for weeks, and all I ended up needing was this override directive. Heads up to everybody having this problem!

Makes my site, www.accurental.com, finally work as it should.
Tenant Screening services website

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

Right on this was exactly what I needed! Thanks

Looks like this is no longer relevant in Drupal 7.12.

Thanks SethVIII. After moving two Drupal sites (one D6 the other D7) to Ilisys's cloud clean URLs stopped working. This setting was just what I needed to get clean URLs working on two both sites.

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

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-Mona for more tips.

Versions prior to 4 already have the rewrite_module line uncommented.

This is really good to know "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." more power..

background check

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

In testing Ubuntu 9.10 I've set up 2 different servers 1) Ubuntu w/XAMMP and 2) Ubuntu with LAMP install from the server installation...both were different in getting this to work. Thanks.....

Great!!! I'm using Linux Mint Helena (based on Ubuntu 9.10) and this works...

Thank you again.

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 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.

Thank you! This worked.

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]

Thanks a bunch.

In debian it worked this.
(Only needed if instalattion of drupal is in the root directory, not in a subfolder. In a subfolder i didnt need this change)

Thank you, i was wondering how to enable clean url's

I installed Drupal (6.9) in a subdomain using GoDaddy hosting. I was initially unable to use clean URLs.

First I changed the RewriteBase directive to "/subdomainfolder". That didn't work.

Next, I added the "AllowOverride All" and "AccessFileName .htaccess" directives to the .htaccess file but that only produced a 500 error.

Lastly, I commented out the "AllowOverride All" and "AccessFileName .htaccess" directives and added a "/" in front of "index.php" in the line reading "RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]" to make it "RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]"

That worked.

In Debian, when you want to use clean URLs with a subpath you can do it in the following way:

  <Location /mysubpath>
    <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^/usr/share/drupal6/(.*)$ index.php?q=$1 [L,QSA]
    </IfModule>
  </Location>

This will give you a Drupal site at http://example.com/mysubpath/

Make sure to update the RewriteRule line with whatever version of Drupal you happen to be using.

See the page http://drupal.org/node/781412 for up-to-date Debian configuration for Lenny backports and Squeeze (Drupal 6.16).

pro-freedom

AddModule used to be used to control the order in which you enabled the different Apache modules. However as of Apache 2.0 the directive AddModule is no longer required (pop to the apache site for a full explanation) so there's no need for
AddModule mod_rewrite.c
unless you're running an older Apache.

Not only it is not required, see:
http://httpd.apache.org/docs/2.0/upgrading.html
but it seems it may provoke an error:

$ sudo service apache2 restart
Syntax error on line 7 of /etc/apache2/conf.d/drupal-7.0.conf:
Invalid command 'AddModule', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.

http://Fiable.biz Web site creation.

Network Solutions hosting is a complete disaster, but if you're stuck with it the following post helped me get Clean URLs working in a D6.10 install.

http://drupal.org/node/11861#comment-18597

This only applies to the shared unix hosting package, where PHP is run through CGI.

In short, you need to create a php.ini file in the /cgi-bin folder at the root of your Network Solutions directory.

Fill the php.ini with the settings from the IfModule mod_php5.c section of your Drupal install's .htaccess. You can't just cut and paste because the ini format is parsed differently than .htaccess.

In D6.10, your php.ini file should looks like this:

register_globals = off
magic_quotes_gpc = 0
register_globals = 0
session.auto_start = 0
mbstring.http_input = pass
mbstring.http_output = pass
mbstring.encoding_translation = 0

Then you need to set BOTH the RewriteBase in your .htaccess file, and the $base_url variable in your site's settings.php file.

Go back to the clean urls admin page, and you should be able to flip the switch.

Some have reported that you need to comment out the Options +FollowSymLinks setting in your .htaccess file, but I haven't had to do so.

It's also worth noting that you won't be able to make it through the install process without errors without setting up a php.ini file as described above to disable register_globals.

I can confirm this still works to enable Clean URLs for Drupal 6.20 in the root directory on Network Solutions Unix Hosting. For subfolder installations Clean URLs will work without configuration changes, but for a root directory install you'll need to uncomment line 107 in .htaccess

  RewriteBase /

And create a php.ini in /cgi-bin with the following:
magic_quotes_gpc = 0
register_globals = 0
session.auto_start = 0
mbstring.http_input = pass
mbstring.http_output = pass
mbstring.encoding_translation = 0

Thanks obrigado!

brent

Network Solutions... not awesome for Drupal 7. All files uploaded with FTP get wrong permissions by default. You need a bunch of custom server settings to get Drupal 7 working without 404, 403, forbidden, admin access denied, and clean URLs, memory limit, or session errors. They have wasted a couple days of my time this week. I read that they are slow and oversell shared hosting, but I am still under development, can't confirm that yet.

Drupal 7 settings for network solutions:
--
php.ini (in the cgi-bin directory above the htdocs web root folder)
Lots of fun server settings here.

register_globals = off;
upload_max_filesize = 20M;
post_max_size = 96M;
memory_limit = 128M;
output_buffering = 2048;
magic_quotes_gpc = 0;
session.auto_start = 0;
mbstring.http_input = pass;
mbstring.http_output = pass;
mbstring.encoding_translation = 0;

--
.htaccess (in drupal install directory)
Use drupal default .htaccess, and uncomment the RewriteBase including your folder name if it's a subfolder of htdocs.

RewriteBase /myfolder

--
settings.php (755 the permissions temporarily so FTP works)
Comment out the $cookie_domain, and uncomment the $base_url and put your URL.

$base_url = 'http://mydomain.com';  // NO trailing slash!

--
Hope this saves some time.

Not all chemicals are bad, H20 for instance is a vital ingredient in beer.

I just installed Drupal 6.10 in a subdomain hosted by doteasy.

I read for hours about Apache Modules and mod_rewrite in particular only to discover that getting clean URLs to work is very easy in this situation.
Maybe this will save you some time:

1. Make sure you include the .htaccess file with the rest of your Drupal files in the directory on the server. Obvious to some, but .htaccess files are hidden by default in OSX and not included in a standard drag-and-drop transfer from your local directory to an FTP client. Installing Drupal is 100% possible without the .htaccess file but enabling clean URLs in a shared hosting environment is not.

2. Uncomment line 101 of the .htaccess file -- the one that has the "RewriteBase /" command

------------------
website | livejournal

Uncomment line 101 of the .htaccess file -- the one that has the "RewriteBase /" command

Thanks so much!

If you have installed Drupal on Aplus in to a subfolder. Be sure to use "RewriteBase /subfolder".

I moved an existing site to another server, but the clean URLs no longer worked. After spending umpteen hours trying to troubleshoot it, I found the problem. Apache has multiple references to the .htaccess file. The first is a "default" setting as follows (even though I had changed the AllowOverride to All, it had no effect because it was overridden later [see below]):

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

The second reference actually overrides the default setting:

<Directory "/var/www/html">
    AllowOverride None
</Directory>

After changing that setting, my clean URLs were all bright and shiny again! :-) Probably a no-brainer for those who spend a lot of time in the httpd.conf file, but it escaped me because I kept referring to the default setting.

I got this from http://quillem.com/node/506 and it worked:

In your httpd.conf uncomment
#LoadModule rewrite_module modules/mod_rewrite.so

and add the following in httpd.conf with Directory config block, replace the path with the path of your Drupal installation:

Options FollowSymLinks
AllowOverride All
RewriteEngine On

Note: there is no "AddModule mod_rewrite.c" needed

Thank you, the RewriteEngine On is what I needed. This was a problem I encountered on a WAMP even though I had the rewrite module in httpd.conf enabled. I assumed the engine was On. Wrong. =0

I just switched from running XAMPP to Zend Server CE on my localhost.
I had a drupal site using clean url's fine and now after the switch, clean url's don't work anymore.
I had to make the switch because xampp was so slow.

In the httpd-vhosts.conf file I have :

<VirtualHost *:80>
    ServerAdmin eric@site.com
    DocumentRoot "C:\xampp/htdocs/drupal_shared/html"
    ServerName drupalsite.dr
    ServerAlias www.drupalsite.dr
    ErrorLog "logs/drupalsite-dr-error.log"
    CustomLog "logs/drupalsite-dr-access.log" combined
</VirtualHost>

I'm using the same .htaccess file that drupal came with (Drupal 6.19).
In my httpd.conf file I changed lines:

#<Directory "C:\Program Files\Zend\Apache2/htdocs">
<Directory "C:\xampp/htdocs">"
    Options FollowSymLinks
    AllowOverride All
    RewriteEngine On

I'm running a multi-site configuration with separate databases.
My drupal sites are in C:\xampp\htdocs\drupal_shared\html

PHP is running as CGI now also. It wasn't before.

Can anyone help with this?

thanks

Eric

Had to change AllowOverride none to AllowOverride All in file:///C:/Program Files/Zend/Apache2/conf/httpd.conf.
I was also getting this warning:
warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for '-5.0/no DST' instead in C:\xampp\htdocs\drupal_shared\html\sites\all\modules\token\token_node.inc on line 40.
Solution:
date.timezone was not set in C:/Program%20Files/Zend/ZendServer/etc/php.ini in
Changed it to date.timezone = "America/New_York"

Eric

Great Job!! This also works for 1and1 customers!!!

Clean URL .htacccess with DreamHost, GODaddy and Bluehost
dannychang - December 26, 2008 - 21:34
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

RewriteEngine on

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

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

-------

I had my head banging on the wall about this ... so easy.

Don't forget, if you installed your drupal under the ROOT, you have to change the RewriteBase to specify which root drupal is installed under.

Like this:
RewriteEngine on
RewriteBase /yoursite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

mod_rewrite & Virtualhosts on Mac OS X Leopard Server

After much trial and error (mostly error). I finally got Clean URLs working on my Mac server. However let me start off by station that my Leopard server does not run the stock Apache, but one that I built form the ports tree because the stock one is a rpita!!! when it comes to php customization. Plus Apple is rather slow to keep up with basic security updates on UNIX ports.

    RewriteEngine off
    <Directory "/Volumes/Data/web/SOMESITE.com/public/">
        AllowOverride Options
        <IfModule mod_dav.c>
            DAV Off
        </IfModule>
        Options All -Includes -ExecCGI +MultiViews -Indexes
        RewriteEngine On
        RewriteCond %{REQUEST_METHOD} ^TRACE
        RewriteRule .* - [F]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
    </Directory>

Thanks to this note I found on the Zend Framework Page regarding mod_rewrite which suggests placing a forward slash before index.php. I did try the tag but that did not work so I moved things around and well struck pay dirt. I shall test this on one of my FreeBSD web servers tomorrow morning and if it work I'll make another note.

I hope this saves someone hours of headaches from not having to knock their head on a wall...;-|

<VirtualHost *>
        ServerName beta.SOMESITE.com
        ServerAdmin admin@example.com
        DocumentRoot "/web/SOMESITE.com/public/"
        DirectoryIndex "index.php" "index.html"
        CustomLog "/web/SOMESITE.com/logs/access_log" "%h %l %u %t "%r" %>s %b"
        ErrorLog "/var/log/apache2/error_log"
        ErrorDocument 404 /error.html
        <IfModule mod_dav.c>
                DAVLockDB "/var/run/davlocks/.davlock100"
                DAVMinTimeout 600
        </IfModule>
        <IfModule mod_mem_cache.c>
                CacheEnable mem /
                MCacheSize 4096
        </IfModule>
    RewriteEngine off
        <Directory "/web/SOMESITE.com/public/">
                AllowOverride Options
                <IfModule mod_dav.c>
                        DAV Off
                </IfModule>
                Options All -Includes -ExecCGI +MultiViews -Indexes
                RewriteEngine On
                RewriteCond %{REQUEST_METHOD} ^TRACE
                RewriteRule .* - [F]
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
        </Directory>
        LogLevel warn
        ServerAlias beta.SOMESITE.com
</VirtualHost>

Cheers,
Mikel King http://twitter.com/mikelking
http://olivent.com
http://jafdip.com
http://mikelking.com

sudo a2enmod rewrite
sudo nano  /etc/apache2/sites-available/default

Edit line 7 to read, "AllowOverride All".
Edit line 11 to read, "AllowOverride All".
Save and exit.

or
Find and Replace All "AllowOverride None" with "AllowOverride All".
Save and exit.

Thought I'd report back.

It's been several hours now and 5 re-boots of my server just in case it was services not starting of something. I must have visited 20 websites and checked everything I could.

Finally I decided to download the trial version instead of the free 'Lite' version. Bam! Working straight away - I guess they don't want anyone to go without paying. I'm sure they deserve their money. I just wish someone would pay me for the hours of banging my head against a wall.

I'm very glad it's working. I just feel a bit flat after so much effort and so many angry thoughts running through my head.

1. make sure mod_rewrite.so is checked on in Server Admin

2. if Server Admin on your system allows you to check "Allow All Overrides" in the Apache Options for your site, you're done. Otherwise...

3. edit /etc/apache2/sites/[0000_your_site_info.conf] (where 0000_your_site_info.conf is a filename corresponding to the site you have created in Server Admin -> Web -> Sites) and make the following change:

  • search for the <Directory "/Library/WebServer/Documents"> entry (if you haven't changed your site's root, otherwise look for the entry with your specified root)
  • change AllowOverride None to AllowOverride All

To get clean urls working with my Omnis hosting account, I had to remove the following from the standard .htaccess file:

# Follow symbolic links in this directory.
Options +FollowSymLinks

Hi

I have a similar problem but when I transfer the site to the final server, it shows me a similar message so what I did was

- check if the rewrite module is enabled

prompt$apache2ctl -M
to see the apache modules

and as it was enable I add this code to my httpd.conf to allow clean URLs

# Various rewrite rules.
<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteBase /home
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>

this works for me. the /home is for my drupal installation location

drupal 6.14
Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.7 with Suhosin-Patch

Hi. I get irritated every time I have to do this, so writing a note for me and for everyone else that it might help:

Setup LAMP on Ubuntu. Create symbolic link to phpmyadmin (just by the way because its annoying to remember):
Setup instructions here: http://www.ubuntugeek.com/howto-install-lamp-server-in-jaunty.html
Creating link: sudo ln -s /usr/share/phpMyAdmin /var/www

Install mod_rewrite:

sudo a2enmod rewrite

Add this to conf (sudo gedit /etc/apache2/httpd.conf):

<Directory /var/www/fridays>
   RewriteEngine on
   RewriteBase /
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
   AllowOverride All
</Directory>

Restart Apache:

sudo /etc/init.d/apache2 restart

Hope that works straight away for someone. Took me 2 hours to work out.

Bruce

Thank you so much for the "AllowOverride All" I was going crazy trying to get my apache2 to start up again and that was just the trick.

Under "Multi-site" above, we find the following prescription:

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?q=$1 [L,QSA]

before the existing rewrite rules.

The $1 in the last line should be %1, since we want to take the back-reference from the last RewriteCond, not from the RewriteRule itself.

If we use $1, we get an extra "mysite/" in the query part of the URL. As an example, for /mysite/target-url we get:

/mysite/index.php?q=mysite/target-url

With %1, we instead get

/mysite/index.php?q=target-url

which is what we want.

Having installed Drupal v6 in a subdirectory /drupal, I wanted to "move" the installation to the root, without having to move all the files up a level. After finding some great posts online, this could be done with a .htaccess file and a few other tweaks, mainly sourced from a post "Getting started with Drupal 6 in a subfolder". In a nutshell:

1. I created a new .htaccess file in the root, containing:

RewriteEngine on
RewriteRule ^$ /drupal/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ drupal/$1 [L,QSA]
(If your installation is in a different subdirectory, you will need to amend the two occurrences pointing to "drupal" to your subdirectory name)

2. I deleted the existing file in the root, index.htm, so that it would not be found and served up. You might also need to remove, if it exists, index.php (actually I renamed the files on the server, so that if I encountered a problem, I could rename it back, and continue with the old site)

3. In sites/default/settings.php, I changed the commented line to:
$base_url = 'http://www.mydomain.com';  // NO trailing slash!

  • I did not need to make any changes to the existing Drupal .htaccess file.
  • I needed to log-in again to gain access to the site
  • I placed my site in Maintenance mode while making the change

I struggled an hour before understanding that the test which allows to enable clean-urls which was failing.
I was modifying my configuration and was refreshing http://localhost/q=admin/settings/clean-urls , unable to enable it.
After validating that mod_rewrite was enabled, I guessed this auto-test was failing, and tried to reload my page at http://localhost/admin/settings/clean-urls . The test succeeded and I was able to enable clean urls :p

I just spent hours trying to figure this out - and finally got it to work trying something I haven't seen listed elsewhere:

I had been opening the httpd.conf file in dreamweaver - editing per instructions found here - then closing it. Turns out, Dreamweaver was adding something to the mix unbeknownst to me. Opening the httpd.conf file in notepad, editing and saving out that way suddenly made everything work. Here are the only changes I made:

1) Per an earlier message in this thread, I removed the hash (#) mark before the following in the .htaccess file:
RewriteBase /
2) I removed the pound sign/hash mark/# before the following in the httpd.conf file:
LoadModule rewrite_module modules/mod_rewrite.so

After saving each of those files, (again, editing in notepad as opposed to dreamweaver) I simply restarted "all services" and refreshed the "clean urls" page on my site and was able to enable clean urls.

Note: I made no other changes; other suggestions/coding found in this thread were unnecessary for my setup (wamp, windows xp home, apache 2.2.11, php 5.3.0, drupal 6.15)

trying to get the Clean URLs page at Home > Administer > site configuration to work properly so the radio button for ENABLED would work. I finally got- "your server has been successfully tested to support this feature"

using Windows XP, WampServer2.0h.exe, MySQL 5.1.33, PHP 5.2.9-2, Apache 2.2.11, Drupal 6.15

working on my local computer:
I found the file named httpd.conf at C/wamp/bin/apache/apache2.2.11/conf
Opened this file using Notepad and removed the # marks from the line that reads - LoadModule rewrite_module modules/mod_rewrite.so

Then I added to httpd.conf as stated above while changing the directory as follows to read:

<Directory /var/www/sites/default>
   RewriteEngine on
   RewriteBase /
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>

Mar

it work perfect for me. thanks for the solution.

Thank you!
I would have never suspected that using http://localhost/?q=admin/settings/clean-urls reported a wrong result, while http://localhost/admin/settings/clean-urls succeeded!

For this reason I did not understand your instructions immediately. So more clearly, what I did after restoring mod_rewrite is just changing the URL in the browser.

June 2012, I just installed D7.14, and had to follow this trick to get clean urls working.

It took me a lot of reading to find it. Why is this problem still in Drupal? Ho would a new user EVER solve that problem??

In Drupal 7 the above comment was the answer that saved me. I was following every piece of advice that seemed appropriate and clicking the clean URL test button to no avail (took about 4-5 hours on solving this problem).

After reading the above comment and simply editing the browser URL manually to a clean URL I finally see it does work and I now see the "enable clean URLs" checkbox.

This isn't a good situation, though, as working clean URLs should be detected by Drupal and it should not keep reloading the page asking the user to press the test button. I hope this can be fixed in future.

Anyway, I'm glad my struggle is now finally over! Thanks to all who posted solutions.

Hi,

I had the same situation and solved like that as well.

Cheers,

Thanks people - this was the threadlet which rescued me from a dead end!

I've done a bug report, http://drupal.org/node/1178850.

For projects hosted on Sourceforge, you will need to uncomment the following line from the standard .htaccess file

  RewriteBase /

and then copy .htaccess in your /home/groups/f/fo/fooproject/htdocs folder, where "fooproject" is your project UNIX name.

My Scenario:

Using multisite in that I have a main installation of Drupal on my server in /drupal

Created 3 sites to run off a single codebase by doing the following:

Create the following sub directories (note the final directory should match the domain name without the "www"):

* /drupal/sites/siteone.co.uk
* /drupal/sites/sitetwo.co.uk
* /drupal/sites/sitethree.co.uk

Created a MySQL database for each site and copied the default.settings.php file from drupal/sites/default into each of the directories created above.

Renamed each instance of default.settings.php => settings.php and input the corresponding database login details so siteone.co.uk could connect to its own database and sitetwo.co.uk could connect to its own database and...

Visited www.siteone.co.uk/install.php to install and repeated for the other two sites.

Read many articles that claimed clean urls would only work if I made a reqrite rule for each site in the main .htaccess file.

No need for that on my server. The only two changes I made were to declare the drupal code directory like so:

### Declare drupal directory ###
RewriteBase /drupal

And changed:
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] => RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
- note the "/" in the latter.

Clean URLS is now working on all three sites.

Through my testing, I must have broken the .htaccess file so I re-downloaded drupal, copied the .htaccess file and made just those two changes and it worked.

My file is attached as a .txt here if you need it as a reference point.

Hi,
the text mentions it removes the query parameter, but it does not say what is the expected format of your URL for a regular node.

I'm finding that to be, for a default install (e.g. no additions to the URL like the country name ../es/.., etc. ) :
domain.com/node/nodenumber
such as
domain.com/node/1234
just as the nodes on the drupal.org site.

I'm looking for SEO friendly URLs for a blog or forum. Is this module addressing this problem?
Thanks

La escupidera - Blog de xmariachi

Mostly, they work. However, on

http://www.jacobkking.com/

On the main page, if you scroll to the bottom and click one of the "next page" links, the rewrite rule doesn't take effect. Instead of getting

http://jacobkking.com/page=1

I get

http://jacobkking.com/node/?page=1

which produces a broken link.

I'm hosted on GoDaddy and these are my .htaccess settings:

   RewriteEngine on
   RewriteBase /
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_URI} !=/favicon.ico
   RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

If you think you know everything, you know nothing.

Hi,

Please, anybody have Idea how to get It running on Windows+ IIS?

tks

Wils
Never is to late for refactoring =D

Clean URLs on IIS (http://drupal.org/node/3854)

Hi Jakery,

Having exactly the same problem. I understand it's been a while since this post of yours, have you found the answer? can you help me please?

Regards,

Mseraphim

I don't know if I have the correct answer (see the last paragraph).

I do remember that the .htaccess file didn't copy from the drupal install zip to my root web directory. I didn't even know it was provided, so I'd built one on my own, and it was missing lots of important rules. If this is the case for you, make sure that the Drupal's default .htaccess file is in your home dir. I don't even know if that will fix the clean URL problem, though.

Another possible issue: I've just looked at my .htaccess file. The line:
RewriteBase /
Is in the my post in the thread, but is not in my current .htaccess file. I'm not sure why this would make any difference, but it's possible that this line was causing trouble. I don't know if this line is in the Drupal-provided .htaccess file, but you can try commenting this line out and see if it makes any difference.

Truthfully, I don't remember how exactly this problem got fixed. A couple months after I posted my issue I completely lost my web site's files and database tables (my backups were on a hard drive that had just failed), so I had to start from scratch. It's very possible that I'd incorrectly installed Drupal the first time around, and the clean install was the real fix. Hopefully, you won't have to do something this drastic, however.

Good luck.

If you think you know everything, you know nothing.

Thanks for your comment, but the RewriteBase seems like it is used when your drupal site is in a subdirectory. ex. Normal installation would be http://localhost/drupalsite and subdrirectory would be http://localhost/subfolder/drupalsite. If drupal installation is in a sub folder, then it would look something like this in the .htaccess: RewriteBase /subfolder

In my case RewriteBase / is commented out.

I have done so much work on this site and to do it all over again on a new drupal install is almost not worth the effort.

I haven't changed anything in the drupal files except for the page.tpl.php. And that change was to enable no title content types like pages without titles. Maybe I could make a new installation, copy changed files over, still use the current database. don't know it it will work. I'll give it a try and let you know, might takes some time though.

Regards,

Mseraphim

Hi all you guys,
I've trying this for about a week unsuccessfully (maybe I need a different point of view). My hosting is SeekDotNel, which provides PHP hosting over DotNetpanel (I mean any kind of .NET based manager over IIS), but it parse .htaccess a little bit weird b/c Rewrite* options are not enough for it, I mean it throws the following error:

DotNetPanel IIS Modules Error
AuthName directive not found.
File: C:\HostingSpaces\mainsite\maindomain\wwwroot\.htaccess

So I thought, in order to remove alert, it requires a kinf of authentication configuration like the following:

AuthType None
AuthName Unrestricted

But it neccesarilly demands AuthUserFile (AuthUserFile /sec.db) and my site turns in something unaccessible.

Any ideas? Thanks in advance.

see Clean URLs on IIS (http://drupal.org/node/3854)

I have problem setting up clean url for my nginx web server. I tried some hints here and there on blogs, but with no success. Regarding that a considerable portion of drupal sites run on nginx servers, I am wondering why the instruction is not included here yet, and I wish someone can do so.
Cheers

Hello! Look at article http://hostingfu.com/article/running-drupal-with-clean-url-on-nginx-or-l...
For my Drupal 7 started under nginx only that solution works - write in your /etc/nginx/sites-enabled/hostname.file something like:

location / {
        root /var/www;
        index index.php;
        error_page 404 = @drupal;
}
location @drupal {
        rewrite ^(.*)$ /index.php?q=$1 last;
}

This worked in early drupal 7.x versions. There is example for drupal 7.4 & nginx 0.8.54 - http://kbeezie.com/view/nginx-configuration-examples/ :

location / {
# This is cool because no php is touched for static content
try_files $uri @rewrite;
}
location @rewrite {
# Some modules enforce no slash (/) at the end of the URL
# Else this rewrite block wouldn't be needed (GlobalRedirect)
rewrite ^/(.*)$ /index.php?q=$1;
}

Hi, I try both of your examples but still can't enable Clean Urls

nginx version: nginx/1.2.1
drupal: 7.12
PHP: 5.3.10-1ubuntu3.2 (more information)

any other ideas ?

I was able to enable Clean URLs under Drupal 6.16.
But I can't under Drupal 6.17 with the same settings.

<Directory "/opt/lampp/htdocs/drupal-6.17">
   AllowOverride All
</Directory>

I also tried:

<Directory "/opt/lampp/htdocs/drupal-6.17">
   RewriteEngine on
   RewriteBase /drupal-6.17
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>

There must be some change in 6.17 that makes this problem.
What could that be?

u can see post " a fix that worked " above this post. I work D6.17 and this ok w me.

6.17 worked for me, out of the box. I had problems initially because I hadn't copied the .htaccess out of the drupal-6.17 dir and into my new site...

FC10, apache 2.2.14

If you can't get the clean urls to work, you may just be missing the simple user path in your .htaccess file This is almost always the case.

instead of RewriteBase /

you need to add the ~user (user being the name of your cpanel account)

RewriteBase /~user

for those on hostgator you can find this on your welcome/setup email its very simple to because it is 99.9% going to be your cpanel username. Don't forget the ~ before it. You should not have to have any additional path after this just the /~user

It's amasing how much trouble this is causing people (and me!)

I'm on Wiserhosting.com which uses cpanel. I tried all the tips in the comments above until I reached yours redlance. It turns out I completely forgot the tilde (~)! Bugger...

All I then had to add was 'RewriteBase /~user' and now it seems to work.
Although images don't seem to load now. hmmm. The address for images comes out as http://www.example.com/node/sites/default/files/images/image.jpg /node/ is not supposed to be there. More work to be done.

On Modwest you need to add:

RewriteBase /

under

RewriteEngine On

to get clean URLs working.

I had my head banging on the wall about this ... so easy.

Don't forget, if you installed your drupal under the ROOT, you have to change the RewriteBase to specify which root drupal is installed under.

Like this:
RewriteEngine on
RewriteBase /yoursite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Thanks Rennes.

Took me one day to find this solution...

On 1and1 dedicated managed server after installing above code in the .htaccess I get the following message on the clean URL configure page (?q=admin/settings/clean-urls):
"Your system configuration does not currently support this feature. The handbook page on Clean URLs has additional troubleshooting information".
I setup a subdomain to point right to the drupal root directory.
Please advise,

Yes, this solution is ok actually
Thanks

this work thank you all for help very appreciated have a nice one :)

Hello people, I really need help with this one.

Is there any alternative solution, even a far-fetched workaround, to solve this problem, other than the ones given above?

I have checked (it's on a shared server):
- the .htaccess file is present
- the .htaccess file is NOT ignored
- drupal is NOT in a subdirectory
- uncommenting RewriteBase / does NOT work
- changing RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] by adding an extra / does NOT work

I've found 100.000 solutions online but they all come down to these five points that I have checked over and over again.
Is there ANY other solution? I'm really pulling my hair out right now?

Thanks,
Koen

Sometimes it works to do it all again step by step. To get my clean URL's to work I :
1. Downloaded the original .htaccess file to my computer.( it may show up as .htaccess[1] )
2. Opened it up with Wordpad instead of Notepad--Notepad shows everything jumbled up.
3. Found the '#RewriteBase / drupal' code and deleted the '#' and the 'drupal' so it looked like: RewriteBase /
4. Hit Ctl S to save it--Don't "save as" I think this messed me up the first time.
5. Uploaded it to server
6. Renamed the .htaccess that was already on server to '.htaccessOLD' in case I messed something up.
7. Renamed the .htaccess[1] that I just uploaded to .htaccess
8. Reloaded my wepage, logged on and went to Administration>Clean URL's and
Voila I was able to click the radio button for clean URL's.
I am a super newbie and have found my webhost 1and1 to be very helpful with my Drupal questions so far. I hope this helps.

You saved me year s of frustration... thanks it worked sooo easy and your directions were spot on...

I'm testing D7 beta1 (on IIS) and confused a bit:
Q1. No problem till to the "Administer > Configuration > Search and metadata > automated Clean URLs test" step, but then no "Enable clean URLs checkbox" appears to check/uncheck. Any idea?
Q2. Which table/variable keeps this setting?
Q3. Does $conf['clean_url'] = 0; (or =1) in settings.php overrides this setting? I checked but observed no change.

@subscribing

----------------------------------------------------------
- R Karajgikar

I had exact same problem on D7 Beta1 on CentOS. If the .htaccess file is missing or absent, the checkbox for Enable Clean URLs does not appear on the screen - it only lets you run the test and it is a bit confusing.

I noticed that there was no .htaccess file in the drupal document root. I copied the .htaccess from the Drupal7 beta1 folder into the installed drupal document root and the checkbox appeared on the screen.

I hope this helps others facing the same situation.

----------------------------------------------------------
- R Karajgikar

I have the .htaccess file in the drupal document root. Still I can only get the test, not the checkbox.

I have the same problem. I tried changing the .htaccess file as listed above, but it had no effect. I run the clean urls test, and absolutely nothing happens other than that the page seems to reload.
This is also on Drupal 7 beta 2. I'm currently running on a friend's ubuntu server. I have another drupal 6 site running in a different subdirectory on a diff database that has clean urls working just fine.

Jen C. Harlan
Classical Music Consortium of Austin

I had the same problem, what I needed to do was to change "AllowOverride" to All in the apache configuration.
Before I got a simple page reload whenever I clicked on Test, after the checkbox to enable clean urls...

It was the same as I did, and it solved the problem: "AllowOverride All"

Try uncommenting the following line in your .htacces file and re-running the test.

RewriteBase /

One of our clients has a D6 site with hosting by British Telecom (BT) . We needed to make a single change to the last line of the Rewrite URL section in the .htaccess file in order to enable clean URLs (hosting package was "business, starter" I think). As noted in the "Location of index.php" section of the handbook:

# 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
# Add a / to index.php?q=$1 [L,QSA] to enable support on BT server
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]

Note that the following will produce an error on some Amazon EC2 servers:

AccessFileName .htaccess

Just try doing without it -- in this case, I found it to be unnecessary.

I see that clean url still makes a hot issue until 2010! i have my problem too

In my case, i have 2 drupal installation on fedora 12,
1. in document root -> http://localhost/drupal/ (in filesystem: /var/www/html/drupal/) and
2. in homedir http://localhost/~hendro/drupal2/ (in filesystem: /home/hendro/public_html/drupal2/)
(note: hendro is my fedora logon username)

clean url for the one in document root is working fine, but NOT in homedir.

i searched and searched the internet, and played around with the .htaccess file in /home/hendro/drupal2/.htaccess, with no luck

any help is appreciated

hendro

i have solved it from drupal posting (Clean URLs in Mac OS X Server):
http://drupal.org/node/134814

i use this RewriteBase line in the .htaccess file (the one in /home/hendro/public_html/drupal2/.htaccess):

RewriteBase /~hendro/drupal2

no need to restart apache, and it works.

thanks for everybody who post their problems and solutions in the internet!
hendro

Even after Googling endlessly, reading and re-reading the instructions over and over again and banging my head on the wall for two days in a row, I just could not get CleanURLs to work in Drupal 6.19 on OpenSuse 11.2... I did everything by the book. I even tried removing and then re-installing everything - apache2, php5, mysql... Nothing! I tried reverting to an earlier version of Drupal... Nothing!; changed versions of everything.. including modules. Nothing!! I even contemplated forgetting all about Apache... forever!!! and switching to something else (say Lighttpd or Nginx... Aaaarrgghhh!! (Couldn't just bring myself to that point... yet).

Finally, when I was about to bang my laptop on the wall and give up, I got it! Just follow the instructions in this page *except* DO not edit /etc/apache2/httpd.conf. Instead change AllowOveride All in /etc/apache2/default-server.conf. That's it. One line!!! Damn, how daft am I really?!!

Remember, if your install is in a subfolder off of the root (eg /srv/www/htdocs/site1/), then edit /srv/www/htdocs/site1/.htaccess, change RewriteBase from / to /site1.

I do not know about other distros, but just in case.... there you have it!

TEACHING is the BEST way TO LEARN

Thanks a lot for this info. Just installed Drupal 7 on openSUSE 11.3 and was stuck at this point with the Clean URLs configuration page simply refreshing and showing nothing else each time I pressed the button. Thought I'd try this comments list from the bottom up since there's little relating to v7 already. Mercifully I found yours straight away, and I finally got it working.

In my case I have my primary site configured under a multi-site setup using virtual hosts, so I went into /etc/apache2/vhosts.d/{sitename}.conf and changed AllowOverride to All. Or in full, that file now reads:

<VirtualHost *>
DocumentRoot /srv/www/htdocs/drupal
ServerName {sitename}.localhost
<Directory /srv/www/htdocs/drupal>
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>
</VirtualHost>

Restarted Apache and that was it. Seems fine now.

Just wanted to share a solution to a very specific problem with clean URLs - I was working on a site that used /entries as a path for a number of different pages, but they never, ever worked when Clean URLs was enabled. Views worked, admin worked, regular nodes worked, and I couldn't for the life of me figure out what the problem was.

Turns out, .htaccess has, at the very top of the file, the "FilesMatch" declaration. For my server configuration (and maybe on yours as well?) if you have a path that matches a string from the FilesMatch declaration, you'll get a 404 or 403. To fix it, simply edit the .htaccess file to remove the particular string between pipes, e.g., remove |Entries*| and |entries|

I had the overlayed Clean URLs test dialog just reloading whenever I tried to enable clean urls.
No amount of trying the suggestions above seemed to be solving it (and my D7 is in my doc root so RewriteBase should be / )

In the end I tried calling the "dialog" page directly at http://hostname/admin/config/search/clean-urls
This time it seemed to work.

Not sure the fact the host is an EC2 instance may be significant (some network translation between the VM and inet?) or whether this is generic problem - I've not got another available host to try it on to validate.

exactly that solved my issues with clean urls.

i have no idea why the test did not redirect properly but going to http:///admin/config/search/clean-urls finally showed the check box :-)

i guess there is a little problem with redirect rule caused by not catching www and none www urls of the same domain. but that is just my thought.

I tried this with the wild card redirect and it worked for me. Many thanks. Make sure to check out my utility carts site here.

RewriteBase = /~username/directory_where_drupal_installed(if root leave it)

lIvE LiFe LIke A KiNG sIZE

Hello, I'm having a big problem with my website and I will need help.
I have clean url on drupal and everything was great until I notice drupal wasn't displaying in browser the right url, it was displaying www.example.com/node/44 and it was supposed to have www.example.com/about.
This page 'about' have another sub-page attacked in 'input format' and everytime I selected the rigth sub-page to be displayed there I save but drupal deselected it and I get nothing. Nothing on browser (clean url) and nothing on my view...
It was great one day on the other day I notice this... Can anyone help me????? Please????

I'm really losing my hopes about drupal....

You must install Global Redirect

I also have that. I have everything right...
My website was fine and working great. On the other day out of the blue, stoped working properly and I notice several issues!

If I enter the path manually mysite/mypath it works fine, but the menu links still shows the ?q=. Ran the "Test Clean URL" but nothing happens after it runs, same screen is presented. Running multisite environment: dev/site1 dev/site2 dev/site3 (Any help guys?)

Sounds like the test for Clean URLs is failing, although they are working, they are not being emitted by Drupal. Perhaps check for other ScriptAlias as per my comment below?

Same thing happens for me, but only on 1 of my 3 drupal sites. They are all hosted on the same shared hosting server, as separate drupal installations.
I have enabled clean URLs on 2 sites, but on the third, it has the Run clean URL test button, but when I click it, nothing happens.
so what is going on? and why would it work for 2 sites and not the third? even though all are the same version of drupal?

i have install drupal 7.0. but my URL is www.example.com/d7m.that i used at the installation time. How i will change mu URL to www.example.com

We are having the same issue as johacami on March 1, 2011 at 11:31am.

I used Bitnami stack. ( www.bitnami.org )
I have created two websites. In website 1 the clean URL is working fine
http://localhost/website1/Contests/international-music-composition-compe...
But the other isn't, when I put this link
http://localhost/website2/content/port/crete
I receive the following error
The requested URL /Program Files/BitNami Drupal Stack/apps/website2/htdocs/index.php was not found on this server.
I can only use this link
http://localhost/website2/?q=content/port/crete

I highly need the clean url to work, for me to able to use contextual filter in views.

Spent some time running down why Clean Urls weren't working on an Ubuntu 10.04 installation.

I also have a Mailman installation running on this site and the default ScriptAlias commands for Mailman would cause the Clean Url test to fail, even though all other items above checked out. Commented out the script aliases (accessing mailman at site/mailman instead) and Clean Urls work fine.

Presumably the test for Clean URL functionality uses a url under site/admin, which conflicts with the admin ScriptAlias for mailman.

On hostgator I struggled for quite a while with trying all the different sugestions here, until I had a good look at the .htaccess and at the bottom of the file found that the "RewriteEngine" switch was set to off. Just change it to on and it works :)

Hope this helps someone out there

Regards
Gunter

I've been having trouble getting this to working with Drupal 7 on the host iPage (not recommended) for a while. Finally, I tried changing ".htaccess.txt" to simply ".htaccess" and everything works like a charm now.

I spent a great number of hours messing around with different solutions, on IPAGE you have to change ".htaccess.txt" to simply ".htaccess" . This worked perfectly, THANKS WIllGFP. Drupal 6.22

Kedy Augustin

Re D7 and Clean URLs not working as per usual.

Answer for me was to download and install the Global Redirect module for D7: http://drupal.org/project/globalredirect

Following installation I went to Clean URLs: admin/config/search/clean-urls to enable clean urls (this did not work before installation of /globaldirect module)

All works absolutely fine now.

Thanks! Hope this helps someone...

cheers,
allanx
perth - western australia
---
web design | development | maintenance: http://radicalhack.com

I had to modify as follows before it would enable clean urls option in the admin setting for clean urls:
# RewriteCond %{REQUEST_URI} !=/favicon.ico
# RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
#the following mods were necessary for my localhost with directory var/www/radiospares
RewriteCond %{REQUEST_URI} !=/radiospares/favicon.ico
RewriteCond %{REQUEST_URI} ^/radiospares/(.*)$
RewriteRule ^(.*)$ /radiospares/index.php?q=$1 [L,QSA]

Thanks, this worked for me.

I have just started working in drupal , I am running drupal 6.2 on windows , when I try to enable clean url , the radio buttons named as follows are disabled

Clean URLs:
Disabled
Enabled
---------------
I tried to enable these buttons by adding the following code in .htaccess file

RewriteEngine on
RewriteBase /drupal
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

but i am not able to make it enabled , drupal is running in the root directory

if anyone have any idea please mention the workable code

thanks

Basant gaur

Please try this one in .htaccess file

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

avkr

Complete these steps in order and you should be ok
http://ycsoftware.net/drupal-7-clean-url-fix-ubuntu-open-atrium-red-hat/

Rather than The following may work, it'd be better to say that a2enmod is a Debian script, as such working also for Ubuntu, enabling a module of Apache2 by creating a symbolic link in /etc/apache2/mods-enabled pointing to a file of the same name in /etc/apache2/mods-available. See
man a2enmod

http://Fiable.biz Web site creation.

After searching what is going, because I couldn't even enable Friendly URL's (there was no checkbox), I found solution. After clearing the cache in the admin/config/development/performance menu, the clean urls are finally working.

I solved CleanURLs problem..

it is very simple

In .htaccess file just change

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

Thanks

avkr

Scratched my head on this for quite a while and found few things to pass on
Problem: Clean URLs not displaying check box to Enable clean URLs
Solution:
Note: I have complete control over my web server so did not need .htaccess files and normally have to delete them or get "Internal Server Error" error message displayed

I use standard (pretty much default) httpd.conf settings with one change

# AllowOverride None
AllowOverride FileInfo
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

Had to create an .htaccess file that only included (excluding normal comments) the following

RewriteEngine on

RewriteRule "(^|/)\." - [F]

# 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 /drupal
RewriteBase /joe1

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

Note: Easy test to see if Clean URLs is enabled (even if it fails when you try it).
After you think you have enabled it, or tried to, then hover your mouse over one of the menu icons and notice what the URL looks like. That is a big clue is you are moving in the right direction.

Also an easy way to set the Clean URLs setting is to do the opposite of the instructions located at http://drupal.org/node/5590

Hope this helps someone

Later

As apache docs states:

AllowOverride Directive:
Only available in < Directory > sections.

AllowOverride is valid only in < Directory > sections specified without regular expressions, not in < Location >,
< DirectoryMatch > or < Files > sections.

What means it should be used in your virtual directory configurations. If you use the default site from the sites-enabled directory within /etc/apache2, or you copy it to your custom site to be it's default configuration (as I did), make sure to enable this directive in the corresponding fields to be able to use .htaccess files.
Secondly, in this case you have to disable Multiviews (what is Enabled by default) in these fields as well:

<VirtualHost *:80>
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options -Indexes FollowSymLinks -MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>

Relevant Apache version: Apache/2.2.19 (Debian) built May 22 2011 08:32:52

Consult the .htaccess file in Drupal page for examples of rules, such as the following

The link points to an invalid URL: http://drupalcode.org/viewcvs/drupal/drupal/.htaccess?view=markup

-----------------------------------------------------------------
They are birds that cannot fly, They are birds that think they're fish.
/penguins

We had the issue where on the local server we could enable cleanurl but on live server the tick box was not coming up in cleanurl configuration.

After having tried some the solutions posed the one that worked for us was to uncomment;

RewriteBase /

in the .htaccess file on the remote directory of Drupal installation.

Al Qureshi

--------------------------
Build with passion...

www.fortrust.co.uk

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

in the .htaccess file inside my public_html/drupal7 folder works for me.

Wanted to post this since I've seen nothing directly addressing this issue with relation to permission settings. So I've been beating my head over this for about a week trying to figure out why I was getting the error message "Your system configuration does not currently support this feature" for Clean URLs. As it turns out, if the Drupal installation directory is set to executable permissions only for other users (ex.: chmod 701 drupal), the .htaccess file will be inaccessible to the the Apache server. After setting the permissions to readable for other users (ex.: chmod 705 drupal), the server was able to access and read the changes made to the .htaccess file.
My initial reasoning for setting the permissions of the directory to 701 was to disallow browsing of directory contents for users other than the owner or members of the user group. Normally files within the directory would still be readable if their permissions allowed for it. However, it appears the Apache server is unable to either read the .htaccess file, or is simply unable detect its existence, when the read permissions for the containing directory are disabled.
Hope this helps someone else out there.

If you run the clean URL test in Drupal on a site that is password protected via .htaccess or server configuration, the test page will reload without any kind of helpful failure message. The problem is that the url test is being initiated from the server on which the site is hosted, and when the server attempts to load the test URL, it's doing so as an unauthenticated user (in the htaccess sense, not in the Drupal user sense). The server will return a result code of "401 - Unauthorized" which the Drupal interface doesn't know how to handle.

The solution is to allow an exception in your htaccess file for the server to access the clean URL address. Any easy (but perhaps insecure) way to do this is to allow host-based access to the site, in addition to certain usersname/password combinations. By including the IP address of your hosting server, you can allow the clean URL test to succeed.

Chris

scenario:

xampp on a local machine win xp with virtual hosts.
making changes to http.conf in apache/conf to add
"LoadModule rewrite_module modules/mod_rewrite.so"

check the .htaccess-file in drupal - root
- several, if you run in sites/default or with "multisite"
(may http://drupal.org/node/43545 help)

!! i make it with virtual domains, so i only have to
type "test" in my browser to access the local - site !!
no matter if a drupal with only one in sites/default or
a drupal with multisite like "sites/test" "sites/test2" and so on.

file "hosts" configured in
C:\WINDOWS\system32\drivers\etc\hosts
like
127.0.0.1 test

file "httpd-vhosts.conf" configured in
C:\xampp\apache\conf\extra\httpd-vhosts.conf
like

ServerName test
ServerAlias test
AddType text/html .shtml
AddHandler server-parsed .shtml
ServerAdmin webmaster@msd
DocumentRoot "c:/xampp/htdocs/drupal"

Options Indexes FollowSymLinks
Options +Includes
# Options +
AllowOverride FileInfo
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.php index.shtml index.html index.htm

what i have forgotten was to make the changes in my
virtual host file of windows.
after checking "Allow Override All" is on there
(default was "NONE") clean-url works.

"Allow Override All" could be found on more than one place
or file - be sure of what you do! or make backups before
playing with these files!

The following relates specifically to my experiences with a Drupal 7.12
'shared-hosting' website (as opposed to an installation on-your-computer; and in my case the web-host is BlueHost.com) and the site was installed using SimpleScripts (an automated Drupal installation process via my webhost's control panel as opposed to FTP manual uploaded installation)
into a website sub-folder (I have never yet tried to install Drupal 7 in a domain's top lever folder);
and also addresses complications if that sub-folder was password-protected before the SimpleScripts installation.

  1. In the case of a SimpleScripts Drupal 7.7 installation into an empty or not-yet-existing sub-folder location, a file named .htaccess.txt is created at [Drupal_7.7-root]/.htaccess.txt, but you need to rename that file as .htaccess

  2. In the case of a SimpleScripts Drupal 7.7 installation into a pre-existing sub-folder that was also password protected prior to the SimpleScripts installation (and therefore that folder already has a small .htaccess file within it), no change is made to that original .htaccess file during the SimpleScripts D7 installation. And...

    • At times, (generally when I have never used the sub-folder name before), the SimpleScripts installation will add a file named .htaccess.txt to the root folder.

    • At other times (generally when I am re-using a sub-folder name again after having deleted the previous D7 installation from that sub-folder) I have seen No additional .htaccess.txt (nor any other variety of .htaccess file) added to the Drupal 7.7 root folder; in which case you need to acquire the large .htaccess file (137 lines of code) that is found by downloading the Core package *.tag.gz or *.zip file to your computer and extracting it.

Details follow.

1. SimpleScripts installation into an empty online sub-folder that is Not protected; or to a not yet existing sub-folder.

By default, when you install Drupal 7.7 with SimpleScripts and allow it to create the new sub-folder; or install D7 into a pre-existing empty folder, a file named .htaccess.txt is created at the top level of your Drupal 7 installation and No file named .htaccess is created.

If you try to enable 'Clean URLs', you will be unsuccessful.

Click the button 'Configuration' at your page top in the administration menu toolbar (This toolbar is present because the Core module 'Toolbar' is enabled by default), and on the page that loads, look under the heading 'Search and metadata' and click the link 'Clean URLs'.

If you click the button 'Run the clean URL test', it will return the exact same page-- no matter how many times you try.

To fix this problem, rename the file .htaccess.txt to .htaccess

If you have any problems renaming the .htaccess.txt file to .htaccess, it is likely because that file has a permission level of 0644. That permission number needs to be changed to 0777 before the file can altered. (Other numbers might work such as 0755, but 0777 has always worked for me) You can change any file or folder's permission level number by going to your web-host's Control Panel and using the 'File Manager' (or similar). Find the file. Highlight the file by clicking it, and then click the page-top button 'Change Permissions' (or similar). If you had to change the permission level of the file, remember to reset the permission for .htaccess to 0644 after you have successfully changed its name.

2011.08.09 - Note from Eric at BlueHost support: "... Also, just as a side note, using 777 permissions is never a good idea. Apache (our web server) actually blocks access to scripts with 777 permissions. 755 should be okay for anything you need to do." -Eric

If your site is in 'Maintenance mode', take it out of 'Maintenance mode'.

Return to 'Configuration' >> 'Search and metadata': 'Clean Urls'. (or 'Refresh' that page if you had left it open in a tab of its own)

You should no longer see the option to 'Run the clean URL test'.

Put a check-mark in the box for 'Enable clean URLs', and click the button 'Save configuration'.

If on the page that loads you see the expression 'The configuration options have been saved.', then you have successfully enabled clean URLs.

2. SimpleScripts installation into a sub-folder that is already password-protected.

If before you install Drupal 7.7 using SimpleScripts, you create and password protect a sub-folder that you intend to use later for your SimpleScripts Drupal 7.7 installation, the password protection process creates a '.htaccess' file within that sub-folder.

That .htaccess file contains only a few lines similar to...

AuthType Basic
AuthName "name of the protected directory"
AuthUserFile "/home1/samplesite/.htpasswds/public_html/sample-sub-folder/passwd"
require valid-user

Then, upon installing Drupal 7.7 using SimpleScripts, that original small .htaccess file remains unchanged, and either a .htaccess.txt file is added to the Drupal 7 root folder; or at times, no .htaccess.txt file is added into the root folder.

If you try to enable 'Clean URLs', you will be unsuccessful.

Click the button 'Configuration' at your page top in the administration menu toolbar (This toolbar is present because the Core module 'Toolbar' is enabled by default), and on the page that loads, look under the heading 'Search and metadata' and click the link 'Clean URLs'.

If you click the button 'Run the clean URL test', it will return the exact same page-- no matter how many times you try.

To fix this problem, you need the proper .htaccess file in your Drupal 7.7 root folder.

  • If the .htaccess.txt file is present...
    1. Delete the small original .htaccess file (which will leave your site no longer password protected for the time being).
    2. Rename the .htaccess.txt file to .htaccess.
  • If the file .htaccess.txt is not present, you need the .htaccess file with 137 lines of code that you would normally have if you were to have installed Drupal 7.7 manually using FTP (or if you had extracted the D7 Core tar.gz [or zip] file via your web-host Control-Panel File-Manager).
    1. Go to http://drupal.org/project/drupal
    2. Download the Version 7.7 'tar.gz' or 'zip' file. (Either one will work.)
    3. Extract that Drupal 7.7 Core file onto your computer system.
    4. Upload the newly acquired .htaccess file.

      This should overwrite the original .htaccess file, but will render your site no longer password protected for the time being.

If you have any problems replacing or deleting the .htaccess file, it is likely because that file has a pemission level of 0644. In that case, the file's permission needs to be changed to 0777 before it can be overwritten or deleted. (Other numbers might work such as 0755, but 0777 has always worked for me) You can change any file's (or folder's) permission level number by going to your web-host's Control Panel and using the 'File Manager' (or similar). Find the file. Highlight the file name, and then click the button 'Change Permissions' (or similar).

2011.08.09 - Note from Eric at BlueHost support: "... Also, just as a side note, using 777 permissions is never a good idea. Apache (our web server) actually blocks access to scripts with 777 permissions. 755 should be okay for anything you need to do." -Eric

The permission level for the new .htaccess file you renamed from .htaccess.txt-- or for the .htaccess file that you uploaded-- should already be 0644; but you might want to check that it is 0644.

Enable Clean URLs.

Note: If your site is in 'Maintenance mode', take it out of 'Maintenance mode'.

Return to 'Configuration' >> 'Search and metadata': 'Clean Urls'. (or 'Refresh' that page if you had left it open in a tab of its own)

You should no longer see the option to 'Run the clean URL test'.

Put a check-mark in the box for 'Enable clean URLs', and click the button 'Save configuration'.

If on the page that loads you see the expression 'The configuration options have been saved.', then you have successfully enabled clean URLs.

If you want to password protect your Drupal 7.7 installation again, you can do it via your web-host's control panel as you had originally done. That process will add the few lines from your original .htaccess file to the bottom of the newer .htaccess file starting below the final line...

</IfModule>

Hopefully this problem will be resolved in the future thus rendering the instructions above null-and-void ...hopefully.

"All the best; intended."
- Chris
___

Drupal 8 is great.

Re: Dupal 9,000
Three-minute Video on the problem
of technology out-pacing users.
http://great-grandma.com/gill_bates-dead_at_42/index.html

Thanks !!! you just made a small comment that was a big help!!!....... you can't enable the clear url while you are in maintenance mode! MAN!!! 3 hours looking for the solution!! thanks for talking the time to do it.

gabe

Hello,

By default Simple Scripts will not enable clean URL's for Drupal or the .htaccess file. This is done for a couple of reasons including numerous requests from hosts and users that had issues with the default settings and the .htaccess file. In almost every case the default package from the script developers is left in tact however in some cases such as drupal if a reasonable change which is easily reversible and does not affect overall functionality can be done we will try to be accommodating. In this situation renaming the .htaccess file which is left in tact will resolve the issue as the link indicated. Unfortunately we cannot account for password protection using a .htaccess file which would be an issue and require a bit of modification regardless of how Drupal is installed.

As a general rule custom .htaccess files in the web root directory can be problematic so we generally discourage running any Simple Scripts processes while the web root custom .htaccess file is still functional. Renaming this file prior to using Simple Scripts is typically a good idea. This is only applicable to the web root/public_html .htaccess file. As the .htaccess.txt file is named to avoid conflict with a default .htaccess files it should always be included in a standard installation. In the event that there is a file conflict including with the .htaccess.txt file Simple Scripts is designed to identify this and notify users prior to beginning the install.

We do appreciate the notification regarding this issue and are currently looking in to some ways to provide user specific feedback for situations such as this in the install and other processes. Our goal is to continue to simplify the process for our less technical users who only want the basics while still providing advanced options and feedback when needed for more advanced users such as yourself. Additional functionality to address such issues will likely be included in the next major update to Simple Scripts which will be coming soon. Thanks again for the information and for using Simple Scripts.

Oli
SimpleScripts.com

"All the best; intended."
- Chris
___

Drupal 8 is great.

Re: Dupal 9,000
Three-minute Video on the problem
of technology out-pacing users.
http://great-grandma.com/gill_bates-dead_at_42/index.html

I installed Drupal 7.7 with SimpleScripts through iPage hosting. The solution for getting Clean URLs to work is being reported as simply changing .htaccess.txt to .htaccess, but for me this causes an Internal Server Error and brings the site down.

Any ideas?

An Internal Server Error suggests that their is a problem with your .htaccess file. If your server has a log directory, you may be able to find an error_log file which details the problem.

It could be as simple as a typo in the file, or an unrecognised, or unsupported command/directive.

I would start with a an empty .htaccess file, try it, and then add lines until your find the line that is causing the problem.

You could see whether this issue has been solved elsewhere (via Google Search)

Hi, I was using this tutorial http://drupaltutorialcenter.com/tutorials/how-setup-clean-urls-drupal to setup clean URL's on Green Geeks, but for some reason it's not working. I don't have root access, so the only thing I can do is modify the .htaccess file. Am I missing something?

The world needs more Drupal Web Design.

That is the essence of the Comment above...
Drupal 7 - 'Clean URLs' problems with SimpleScripts
http://drupal.org/getting-started/clean-urls#comment-4822410

If you have access to .htaccess, that is all you need.

You do not need access to a higher level on your webhost.

Even if your Drupal installation is at the top-level of your hosted site,
the .htaccess file will be within you website's "public_html" folder
(if not within a sub-folder of "public_html"
named according to your site as I am accustomed to seeing)
though at times your website files might be in the "www" folder;
although in my case, going into the "www" folder
actually takes me into the "public_html" folder
as it turns out.

Depending on the problematic present status of your ".htaccess" file,
for example the problem might be that...

  • It is still named ".htaccess.txt"
  • It is named ".htaccess" but, it is essentially a blank file

The problems that I replicated with ease
could all be solved with the simple solution of
downloading to my computer a fresh copy of Drupal Core 7.7,
extracting it, and uploading the .htaccess file to the Drupal-root.

(the drupal root is the folder that houses the Drupal folders,
"includes", "misc", modules", profiles", etc.)

It is important that if you had a .htaccess file already on your site
(as opposed to a .htaccess.txt file on your site)
... it is important that the old .htacces file is destroyed for sure
and is replaced for sure by the new one...
... and that the new one is in fact named .htaccess.

An FTP client will give you its true name.

If, on the other hand, you try to establish the true name of the file
on your computer and you are using Windows, the default computer settings
will hide th file's true extensin name, and likely will hide the .htaccess file itself.

And if using Windows, you open the .htaccess file with, for example,
NotePad or WordPad, and you save it with Notepad or Wordpad,
it could be being saved as .htaccess.txt without your knowing it
if your files on your computer are Not ALWAYS SHOWING their file extensions
(the "period" and last 3 or 4 characters of its true file name).

On Windows XP, for example, (and it is fairly similar on Vista And Seven)
to set your computer to always show
the file extensions, you MUST remove the check box from
"hide extensions for known file types".

Again, on Winwows XP (and similarly located on Vista and Windows Seven
which I have done on each , though I do not remember the exact/ precise details
except to say that you can find it with relative ease)
open an Explorer window on your computer
(Not to be confused with the "Internet Explorer browser"<< not that)
and click in the top main menu the item "Tools"
then in the drop-down menu click "Folder Options..."
and in the "folder options" window, click the top tab "View"
and scroll down the center list until you see
"hide extensions for known file types"
and REMOVE the check-mark from that box.

Additionally,
REMOVE the check-mark from the box
"Hide protected operating system files (recommended)"
since that might be hiding the file .htaccess from you as well.

And click the button "OK" at the bottom of that "folder options" window.

Okay, that's problem one solved. Now problem two..

And if you ever try to name a file as .htaccess from whatever it is named
using the normal Windows XP file and folder viewer window
known as a Windows Explorer window, it will not allow you
and will say something to the effect that "you have to use a name"
meaning that since you have nothing in-front of the "period",
it has no name.

However, if you want to create a file named .htaccess
or rename a preexisting file to .htaccess,
you can in fact use either NotePad or WordPad.

Open the file you want to re-name .htaccess with either, WordPad or NotePad
and then Click "File" > "SAVE AS" the file,
and use double quotes on either side of its name
before clicking "Save". Precisely and exactly like this....

".htaccess"

Saving a file that you specify for its name
".htaccess"
with the double-quotes creates a file named .htaccess.

Similarly if you are creating a new file that you want
to have named .htaccess
(as opposed to trying to rename a file to .htaccess...)
... just make sure you use double-quotes on its front-end and back-end
before you save it and it will turn out named .htaccess

And if you are using your CPanel to try to upload the .htaccess file
(instead of a FTP program... FileZilla is a free FTP program)
then you might not be replacing the old .htaccess file when you think that you are.

The .htaccess file you need to see online should be 5410 bytes; or so.

Good luck, my friend(s).

===

Update 2012.03.10 - Drupal 7.12

If your site is in 'Maintenance mode', take it out of 'Maintenance mode'.

After I renamed ".htaccess.txt" to ".htaccess", the Clean URL test failed for me -- until I took the site out of 'Maintenance mode', and revisited/refreshed the 'Clean URLs' page; at which time the site then began displaying the check-box to enable clean URLs.

"All the best; intended."
- Chris
___

Drupal 8 is great.

Re: Dupal 9,000
Three-minute Video on the problem
of technology out-pacing users.
http://great-grandma.com/gill_bates-dead_at_42/index.html

In step 2 of the section "Server configuration for Clean URLs on a dedicated server, with httpd.conf", the find command should be
find /etc -name "httpd*"
The doublequotes prevent your shell from matching the pattern against the contents of your working directory before it calls the find command. For example, if there were a file called "httpd.txt" in your working directory and you didn't use the doublequotes, you would be running
find /etc -name httpd.txt
without realizing it.

IF your site is broke from clean urls in drupal 7 yoursite.com/?q=admin/config/search/clean-urls provided you are logged in as admin

Another common configuration for a developing Drupal projects on one domain is a sub-domain multi-site.
http://drupal_site.my_domain.com/
http://another_drupal_site.my_domain.com/
The base directory for my site is:
/var/www/
and Drupal is installed in a sub-directory:
/var/www/drupal6
with the multi-sites installed in the sites folder,
/var/www/drupal6/sites/drupal_site
/var/www/drupal6/sites/another_drupal_site

Adding this example would help to confirm there are not conflicts between the rewrite rules for sub-domains and clean url rules and multi-site rules. Here are my working settings on a shared host with PHP running as CGI:

   RewriteBase /drupal6
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_URI} !=/favicon.ico
   RewriteCond %{REQUEST_URI} ^(.*)$
   RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]

Yeah for hostgator this worked when using the ip instead of the domain name, change the following in your htaccess to:

# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
RewriteBase /~yourhostgatorusername

make sure you put the ~ in there

We are still having trouble switching our Drupal6 clients over to hostgator.

We have set it up on server http://50.97.101.200/~temple/

If you go to http://50.97.101.200/~temple/ you get the home page, which is good, but when you click on a link, such as the first one, "Worship Services" then "Overview" the relative pathing is messed up by the /~temple/ (username folder)

http://50.97.101.200/~temple/worship-services/overview

http://50.97.101.200/~temple/?q=worship-services/overview
(see above) If you add a ?q= it will fix that page, but we need to turn it over to them to copy the hundreds of pages & many many links with fixed paths.

Everything would work fine if we could setup the temp site and get copy all entered with the paths as they will work when the domain is pointed, but they will need a couple weeks / months to get everything moved over and tested --- then when the domain is pointed, the links would need to be changed.

We have tried the .htaccess RewriteBase /~temple and all the suggestions on here. Seems that most people backup their site and move it over and make it live, but what about when the site needs to be in temp / testing mode while all the copy is re-org'd? THANKS :)

I am a total Drupal newbie, but am utterly astounded that people have been having trouble with this issue for years and it hasn't been solved. In reading the hundreds of comments/suggestions I've tried several to no avail and am very hesitant to try them all as it would take days.

Is there a general consensus among those who know Drupal well as to how to handle this problem? I've looked at many other pages and they all seem to suggest different things and some even contradict one another. I'd appreciate any suggestions or links. Thanks!

(Seriously thinking of staying with WordPress)

Why not just make clean URLs by default for a drupal installation? Why have a ?q= bit added to the URL if it can be hidden, it's not very user friendly.

Because Clean Urls aren't done by Drupal, their are managed by the server. And that's why they are disabled by default, because some server may not allow Clean Urls, at least not by default.

A system upgrade forced me to redo the Drupal 7 installation using the module to backup and restore the configuration. Since the original site was "clean-url's", I can only see the front page. Using localhost/?q=admin/config/search/clean-urls gets me to the page ok, but I'm not able to run the "clean url test". If there is another way to enable the "clean-urls" please let me know.

UPDATE

Rechecked the httpd.conf Apache config file for "AllowOverride All".
Sure enough, it was not set correctly. Guess it pays to re-read the instructions. 8)

2001:470:1F0F:492::2

added the following to htaccess

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

--------------------------------------------------
Needed a good place to have this. sorry if this bothers anyone
Clean URL .htaccesss

//* Add the following code to htaccess file to enable clean urls *//

RewriteEngine on
RewriteBase /
RewriteCon

This is probably from the 'everyone but me knows that' file, but:

Subject line says it all, after moving a site up to a server and messing with .htaccess and base urls and all the other good advice given here, it occurred to me that path and pathauto also rewrite urls. I turned them off, clean url test passed, turned 'em back on and bob's your uncle.

The 'test' that Drupal 6 does seems to be doing nothing more than looking at the current URL, if it is of the form '/?q=' you are told that your server cannot use Clean URLs; I made the relevant changes to my httpd.conf and refreshed the page 'www.example.com/?q=admin/settings/clean-urls' to see if Clean URLs could be enabled on my system, but nothing seemed to work.

I then tried viewing the page as if Clean URLS were enabled, 'www.example.com/admin/settings/clean-urls', and found that the status had changed, Clean URLS could be enabled, even though NO SETTINGS had been changed!

So the 'mystery' of setting up Clean URLs is really just about setting up a correct rewrite rule for Apache and the 'test' to see if your server is able to use Clean URLS seems to be doing nothing more than just checking the current URL!

Try it, view your site here www.example.com/?q=admin/settings/clean-urls, and I get the report that clean URLS cannot be enabled (you need to unenable it first).
View it here www.example.com/admin/settings/clean-urls and Clean URLS can be enabled (as long as you have the correct rewrite settings).

sigh

using the mentioned steps also works for drupal 7

This worked for me too. Thanks

Why does the http://199.238.172.140/?q=admin/config/search/clean-urls page not contain a check box to disable clean-urls???

The only thing displayed on this page is "Run the clean URL test".

How can I disable clean urls on the website? - The site is running on a shared server, and the host settings mean i can not modify .htaccess or apache configs. I do have access to phpmyadmin.

I think it's probably because you are not using a clean URL, and that is enough for the test to think that they are already turned off. Try this instead:

http://199.238.172.140/admin/config/search/clean-urls

HTH

Had same problem and did what you suggested and it worked great. - Thanks.

Joseph Santos
IT Consultant

Thanks for this one.
I did have to enable the rewrite module (I'm on a new VPS for my current project) but once I did that Clean URLs still were mysteriously not working.
Your suggestion fixed it.

Hi,

After searching lots of sites i came to know about Clean URLS solution on windows 7 (IIS7). We need to add web.config file under Drupal folder where we have files and folders like

  • Includes
  • misc
  • modules.... etc

add web.config file on this root and write the given code to fix clean URLs

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                        <add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

-Ankit Patni

Rename your htaccess file to a text file and use the one that was installed with drupal ie rename it to .htaccess

Works on Drupal 7.9 on hostmonster.com

I couldn't enable Clean URLS. Simple fix, disable Maintenance mode, enable clean URLs, re enable Maintenance mode.

-Shai Perednik
shaiperednik.com

Just point your browser to the clean url and enable it from there: http://[your_drupal_server]/admin/config/search/clean-urls then enable and save. Also to clean up the urls even more, disable the Overlay module. Worked for me.

Ehlo

I don't know why this isn't included in the default drupal rewrite rule but e.g. www.mysite.com/module_menu_hook/company&co does not work, not even if you use www.mysite.com/module_menu_hook/company+%26+co. The $_GET['q'] param will be just module_menu_hook/company. The rest is being cut off. This is because the apache rewrite rule is incorrect. It should be

<Directory /var/www/example.com>
   RewriteEngine on
   RewriteBase /
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,B]
</Directory>

Note the B at the last line => see https://httpd.apache.org/docs/2.2/rewrite/flags.html#flag_b

This way the $_GET['q'] is correct.

This is no longer a problem in Drupal 7. Also note that the B flag is supported since Apache 2.2.7.

Drupal 7 likes to access itself, so if you have a server behind a firewall and are working on a site that isn't directly accessible by the public yet, you will have to edit the hosts file in order for Drupal to recognize that Clean URL's are working. This will also fix up some Status Report problems, too.

Here is an example I was struggling with: I have www.example.com working on my server with a DNS working, and a www folder with a site in it. Updating to Drupal, we create a /drupal folder, load up Drupal 7 and get working with drupal.example.com in our vhost.conf file. After getting everything set correctly, it still doesn't work. We must update /etc/hosts so that the server can see drupal.example.com (so that we don't have to make it live to the world).

I hope this helps someone struggling with this in the future.

So just in case anyone else runs into this issue, I'm posting my experience here.

I built a site in a subdirectory on my server in my sandbox directory (www.mysite.com/website) I had clean urls enabled along with pathauto etc. I transferred my files over into the permanent directory (www.myothersite.com). So now I have both sites running in different directories on the same server. I disabled clean URLS and deleted all the aliases which got the one in its permanent home working properly and allowed me to get into the admin section (before disabling clean URLS and the aliases, only the front page would show up).

So now everything is running great, BUT, I can't get clean URLS to work. I only have the option to run a test and no matter how I configure the .htaccess and config file, the test fails. It shouldn't though. It worked on the sandbox directory, no reason it shouldn't work now. But no. Put in a random string into .htaccess to see if it was being read. Big error, so yes. No reason to go crazy configuring Apache or bothering my host.

One thing. After I got everything working, I put the site in maintenance mode. So I figured what the heck, I'll take the site out of maintenance mode and see if that makes any difference.

BINGO! The test clean URLS button was gone and the lovely enable clean URLS check box was back where it was supposed to be. So, since i didn't see anything about this anywhere I thought I would share.

V 7.12

Not within a thousand years will man ever fly.
-Wilbur Write

...about to pull my hairs off, when I go to your post in this thread. This should be made sticky.

Drupal 6 worked for years on my server. However Drupal 7 returns the error 'The clean URL test failed. ' Strange, because Drupal 6 works. After a bit of searching, i uncomment the default line in .htaccess and added the variant:

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

After this, the error disapperead.

So, check carefully if this line with the RewriteRule is correct.

======
There are 10 people who can count binary
They who can and they who don't

If you're using https with drupal (doesn't matter wich version) don't forget to place 'AllowOverride All' to your ssl.conf!!!

  1. Go to "yoursite/?q=admin/config/search/clean-urls" , you can notice that you can't enable clean_urls
  2. insert the following code to your ssl.conf file (near to httpd.conf)
  3. <Directory /var/www/yourfolder>
    RewriteEngine on
    AllowOverride All
    Options FollowSymlinks
    </Directory>
  4. Go back to the previous url, you'll see no change, but if you delete the "?q=" from the url and press ENTER, you'll notice, that the checkbox appeared. Check+Save! After that clear all your caches, and voila!

see more here

This post really helped me in configuring clean urls on my drupal 7 site.
Thanks for the information

Thanks and Regards,

Asim Shahzad
App Desk Inc.
www.app-desk.com

Hi Guys, VEry Much thanks for you. Was searcing for my clean-url solution for multisite scenario which was not working well in my server. found my solution from the above mentioned code which is to be configured ahead of the already existing rule-conditions. (can find my version of the solution to solve multisite clean url issue in http://drupal.org/node/1510226 )

Thanks

Leon :-)

What worked for me:

mod_rewrite is enabled by default on the Z-Wamp httpd.conf (located in ZWamp/vdrive/.sys/apache2/conf/):
LoadModule rewrite_module modules/mod_rewrite.so

Do NOT add the following:
AddModule mod_rewrite.c
In my case, it prevented Z-Wamp from starting the Apache service.

Add the following section in httpd.conf:

<Directory /web/your-website-folder>
   RewriteEngine on
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>

Please note: "/" is set to ZWamp/vdrive/ by default.
Also, do NOT include the following if you have set the Directory name as described above:
RewriteBase /

drupal 7 site run the clean URL test

"the clean url test failed clean urls cannot be enabled if you are directed to this page or to a page not found (404) error after testing for clean urls"

error messsage
not working clean url

help me?

The default Drupal 7 .htaccess file comes with the necessary directives to allow clean urls to work. So, in most cases, you shouldn't have to modify the .htaacces file that came with your Drupal 7 distribution to get clean urls to work properly. However, you may need to tell the Apache web server to allow the .htaaccess file in your Drupal 7 root folder to override Apache's default directives.

On an Apache web server, putting the following directive in your httpd.conf should work:

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

ReggieW

Just spent a couple hours on this.
I have a D7 install on Amazon AWS (EC2 micro-instance).
I installed the LAMP stack with apt-get install lamp
What I found is that there are separate files created in /etc/apache2 - for example in the site-available directory, there's a default file that holds virtual host directives, unless you put them somewhere else.
Any of these virtual host directives can contain AllowOverride None, especially if you're setting up your virtual hosts with some sort of control panel (I use webmin).
So make sure you've looked in these config files and changed the directive for your Drupal document root to AllowOverride All .

I have many sites work with clean urls, except one... for this, change the value in database, on table "variable" set clean_url value: s:1:"1"; and work!

:)

Matías Miranda Brito
www.perfilweb.com.ar

Hi,
this rule in the Drupal ".htaccess" file worked for me, line 105:
"RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]" (without "...")
the "/" before "index.php?..." was the solution!
Works on site "Hostinger" free hosting:
experimenta
Greetings.

On all the sites I built, all D7, on different servers and hosting companies, I went through all the htaccess and settings.php steps, but every time I got to the same page where it said, 'clean urls can't be enabled' etc.

This until I found that if I pasted "/admin/config/search/clean-urls" directly after my url (so you get "http://yourdomain.tld/admin/config/search/clean-urls" in the address bar, RATHER then clicking through the menu (i.e. following the route "Administer > Configuration > Search and metadata > Clean URLs"), all worked straight away. (That is with the .htacces amended as described above of course..)

Hope this will help someone someday..

CaoutchouC
Branding| Illustration | Graphic and Web Design
London, United Kingdom
www.caoutchouc.co.uk

After many hours of messing with clean urls on a multisite setup on bluehost I finally got it to work. I thought I would post my .htaccess file settings to hopefully help someone else. My site was setup with the main page in /Drupal and symlinks for the other sites like /Drupal1 and /Drupal2 .

RewriteBase /

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

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

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

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

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Hi,

I have a Drupal 7 website running on Windows IIS and the database on MSSQL. If the clean urls is active the website dont create or update any content or setting, when submit any form its return to it and dont display any error.

Anythingelse can help me

Hi,

I currently have problems with uploading images and using clean urls.

When I upload an image to an article page and then I click refresh to view the page, the image doesn't appear. I check for the image url and an example url would be:

"http://example.com/sites/default/files/styles/large/public/field/image/0..."

but the image would appear if I modify the url on the address bar to:

"http://example.com/?q=sites/default/files/styles/large/public/field/imag..."

I have tried:

  • turning on and off clean urls (sometimes the images appear, but then they disappears again)
  • modifying rewrite rules in the the .htaccess file
  • folder permissions

This happened when I uploaded my site to an apache server and the url changes, but doing it locally on my computer, the url doesn't change.

Thank You

This post is the best, we tried everything, up and down, we even went through the 20 minutes waiting for support in Bluehost Several Times and all to receive dumb useless replies to our questions like, "There are chances that your code is wrong" and "You need to ReCheck your Code", enough of the frustration with them, this is what we did:

settings.php - uncomment base url and put your own url
.htaccess

Upload a Fresh Copy from a Drupal Download.
Comment #Options +FollowSymLinks and Add Options +SymLinksIfOwnerMatch right below.

# Follow symbolic links in this directory.
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks
Options +SymLinksIfOwnerMatch

Change the Module ReWrite Settings to this:

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

That should let you activate Clean URLS. BUT if for some reason you moved your drupal installation and you did not deactivate Clean URLS before moving to BlueHost, then you maybe noticed that you will get a download popup from your site if you have .htaccess and you will be able to see your site only if you remove it but you will get a 500 Error on every link... well if that happened to you, then you need to do all of the Above plus the following:

- Do the Above Steps
- Access your website using yoursite.com/?q=user ( login )
- DeActivate Clean URLs using yoursite.com/?q=admin/settings/clean-urls

and TODO BIEN !!!

Thank you all that helped in this post to find our solution, We hope our post can help others!!

With the hundreds of issues posted with people having problems uploading files, not many identify it's after clean url's are enabled. Could someone please offer a solution? It doesn't happen on a new install so I am assuming it may be a certain module but like clockwork I can enable clean url's and then unable to upload any type of file. The system doesn't even recognize the file is there and throws the "may file size limit error". Disbale clearn urls, uploads perfect. This happens on images, pdf, txt, etc.

I have 4 sites, 3 old, one new, all drupal 7. new one, no problems, one old one, no problems...have copied ,htaccess, settings.php, php.ini files from old one that works to old ones that don't work....still no luck.

Is there a list of certain modules that are effected by urls? Or some other solution for this?

Thanks

this is actual error when viewing page element after trying upload -

Failed to load resource: the server responded with a status of 404 (Not Found) http://www.mysite.net/file/ajax/field_other_id_verification/und/0/form-M...

It seems it is looking for a file that doesn't exist BEFORE it tries to upload my file or it's trying to load something into a temp folder and can't get access.

Interestingly, there is not a /file folder.

It works if you do not click on upload(ajax) button and simply save the content.

So, something to do with ajax and clean url's maybe?

I've setup a few servers over the past couple years and yet have found myself returning to this page in exasperation more than once. The servers are generally use subfolder multi-sites, e.g. http://myserver.example.com/site-1, http://myserver.example.com/site-2, etc. Hopefully the D7 example below will help future me jog his/my memory along with anyone else who happens to view this comment:

  1. I make sure that AllowOverrides is enabled on the docroot or the Drupal core directory in the Apache configuration. Otherwise, none of the rest really matters. If you do edit httpd.conf, be sure to reload or restart Apache. Missing that step's cost me hours of troubleshooting I can never get back.
  2. I then setup the rewrite directives in the shared core's .htaccess file:
    #   RewriteBase /
    # rewrite for http://myserver.example.com/site-1
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_URI} !=/favicon.ico
      RewriteCond %{REQUEST_URI} ^/site-1/(.*)$
      RewriteRule ^(.*)$ /site-1/index.php?q=$1 [L,QSA]
    # rewrite for http://myserver.example.com/site-2
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_URI} !=/favicon.ico
      RewriteCond %{REQUEST_URI} ^/site-2/(.*)$
      RewriteRule ^(.*)$ /site-2/index.php?q=$1 [L,QSA]
      # RewriteCond %{REQUEST_FILENAME} !-f
      # RewriteCond %{REQUEST_FILENAME} !-d
      # RewriteCond %{REQUEST_URI} !=/favicon.ico
      # RewriteCond %{REQUEST_URI} ^/(.*)$
      # RewriteRule ^ /index.php [L]

    Note: I've tried the setup with and without rewrite base and the base rewrite rule (for "^ /index.php") enabled and not seen a difference. It seems to matter more (enabled) when the site(s) are off the server or virtual host's docroot. Most of the problems I encountered were with overrides not being enabled for .htaccess, or misspelling of site directories.
  3. If you're a Shibboleth user you may need to add the following rewrite condition to each rewrite rule block:
    RewriteCond %{REQUEST_FILENAME} !Shibboleth*
  4. From there I visit the Clean URLs page (e.g. http://myserver.example.com/site-1/?=admin/config/search/clean-urls), and can finally see the elusive checkbox. Whew!

--
afn
Brown WebServices
http://brown.edu/it/webservices

For the complete novice to Drupal: If you're using GoDaddy as a host and you're having trouble getting clean url's to work like me. Maybe you're not getting the checkbox to turn on Clean URL's when you go to the page to enable them. Before you get up to your neck in mod_rewrites and .htaccess files, be sure to look for a file called "example-web.config" in your directory (folder) where drupal is located. Change the name from "example-web.config" to just "web.config". You'll immediately be able to enable Clean URL's.

Is there any way to exempt a specific URL from the clean URLs? We have an educational website and we need to pass certain information via URL into a custom script. For example, www.site.edu/form?plan=DATAHERE. The data is being passed if it is linked...
<a href="http://www.site.edu/form?plan=DATAHERE">link</a>

However, the trouble comes in when you copy and paste the URL into a browser. Unless the user has already visited the site, the data is not passed. Everything after ? is stripped. But if the url is re-pasted a second time, the data is passed correctly.

In case anyone has the same problem as me being unable to use clean urls when using virtual hosts. To get virtual hosts to use Drupal's htaccess file I had to add "AllowOverride All" to my httpd-vhosts.conf

<VirtualHost *:8888>
DocumentRoot "/mypath"
ServerName mysite.local
<Directory "/mypath">
AllowOverride All
</Directory>
</VirtualHost>