As I have multiple Drupal sites on my server, I am attempting to enable clean urls via the httpd.conf file.

I am using the following code:

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

However, when I visit check the Enable clean URLs box and click the save button, my website just reloads as my index.php file showing the phpinfo() data.

Can anyone tell me where I'm going wrong, please?

  • Why aren't you using settings from .htaccess?
    – Mołot
    Commented Nov 18, 2013 at 13:50
  • @Mołot: From material I was reading earlier, the .htaccess file is for individual websites. I'll have to repeat the setting for all my sites. Unless I misunderstood the text, using the httpd.conf file will apply clean urls to all the websites
    – sisko
    Commented Nov 18, 2013 at 13:53
  • Well, kinda. But having the redirection rules both in httpd.conf and in supplied .htacces is a recipe for disaster. Also, global RewriteBase might mess up things. So, you have needed set of rules for each sites, provided with core's .htaccess. Was it not working for you? Why are you changing that?
    – Mołot
    Commented Nov 18, 2013 at 13:55
  • @Mołot: complete novice at .htaccess configuration so excuse my missteps. All I'm trying to do the enable clean URLs on my drupal site but without success. As I mentioned earlier, I found a post that suggested using the httpd.conf file. If you can give me direction on how to get clean-urls working from .htaccess I'll be very grateful
    – sisko
    Commented Nov 18, 2013 at 14:15
  • And what exactly happens when you use only provided .htaccess and OS-default htppd.conf?
    – Mołot
    Commented Nov 18, 2013 at 14:16

1 Answer 1


It is hard to tell what your exact problem is, but the default .htaccess does more than just redirect requests to index.php. It

  • Protects certain directories and files from being accessed
  • Set up safe PHP defaults for those with old configurations
  • Sets up some baseline cache rules
  • Redirects directory/file not found to index.php

In addition, the catch-all rules that you are using is not the correct one for Drupal 7.

Unless you really know what you are doing, you should keep the .htaccess in each Drupal site's DOCROOT, and then configure your server to support multiple sites using the normal methods. You really shouldn't have to do any configuration specifically for Drupal, other than potentially needing AllowOverride All. Personally, I use virtual hosts on all of my servers. The Apache config for each site essentially looks like:

<VirtualHost *:80>
  ServerName www.example.com
  ServerAlias example.com *.example.com

  DocumentRoot /var/www/example/docroot

  <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
    RewriteRule ^(.*)$ http://www.example.com$1 [L,R=301]

  <Directory /var/www/example/docroot>
    AllowOverride All

That could run just about any site on the planet, Drupal, PHP, or otherwise.

On high volume sites, it sometimes makes sense to avoid .hatccess files (they are scanned every request), and place everything in your apache config (where it will be parsed/stored upon startup).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.