1. Enter Apache 2.2 conf directory:

    > cd C:\Program Files\Apache Software Foundation\Apache2.2\conf
    
  2. Open httpd.conf
    > notepad httpd.conf
    
  3. Uncomment loading of read-write module by removing #:
    LoadModule rewrite_module modules/mod_rewrite.so
    
  4. Uncomment including virtual hosts delaration file by removing #:
    # Virtual hosts
    Include conf/extra/httpd-vhosts.conf
    
  5. For declaring only localhost
    1. create or clear contents of file conf/extra/httpd-vhosts.conf
    2. Copy and paste the following in this file:

      <Directory />
          Options FollowSymLinks
          AllowOverride All
          Order deny,allow
          Deny from all
          Satisfy all
      </Directory>
      
      <Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs">
          Options Indexes FollowSymLinks
          AllowOverride All
          Order allow,deny
          Allow from all
      
          RewriteEngine on
          RewriteBase /
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
      </Directory>
      
      # Use name-based virtual hosting.
      NameVirtualHost 127.0.0.1
      
      <VirtualHost 127.0.0.1>
         DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
         ServerName localhost
         DirectoryIndex index.php
      </VirtualHost>
      

Jeff in Seattle

Comments

shaunak’s picture

Very helpful post.

I would also like to add that you also may have to set the "AllowOverride" directive to "All" [around line 224 in the httpd.conf file] to allow directives in the .htaccess to work.

dmartin’s picture

@shaunak
Thanks so much. I've tried everything under the sun, and it didn't work. Your post led me to this in my httpd.conf:


Options FollowSymLinks
AllowOverride None

Which was overridding every single thing I tried, and I didn't even know it. As soon as I changed None to All, boom, it was working.

sythiar’s picture

Hello. I did everything as you said in the post.
Since I'm using WAMP I also changed the Document Root from "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs" to "C:/Program Files/WAMP/www".

However, the radio buttons on the Clean URLs page remain grayed out. Also the notice "Your system configuration does not currently support this feature. The handbook page on Clean URLs has additional troubleshooting information." remains.
What did I do wrong?

olkl’s picture

Thank you, Jeff, it worked first time for me! I'd just add that one must not forget to restart Apache to see the difference...
Oliver

vertikal.dk’s picture

Jeff's solution didn't work on my system, so I started tweaking it, and actually discovered that something much simpler worked fine for me.

In stead of including the extra file I made the changes to the main httpd.conf file.
Since I already had a ton of virtual servers set up on my local machine, this seemed more logical.
I cleaned out most of Jeff's code and wound up with two small changes:

I set AllowOverride=All for this to work at all. If not set, Drupal's .htaccess file (and other .htaccess-files) will be ignored, and it's an important part of the puzzle.
I also made sure that the rewrite module was enabled as Jeff noticed.

Once those couple of changes were made, I restarted Apache and went to /?q=admin/settings/clean-urls in one of my local sites.
It was enabled and it worked once I ticked clean URL's on and saved the settings. I could do the same for all my virtual Drupal-sites with no hassle.

Martin

Freakz_’s picture

Jeff thanks for the great solution.

I didn’t work for me thou, but it put me on the right track.

The reason it didn’t work for me was that in my .htaccess file under the following part:

IfModule mod_rewrite.c
RewriteEngine on

I had the option “RewriteBase /drupal” enabled.

As I’m running Drupal from my root I had to change this to “RewriteBase /” (actually I just commented out the entry and uncommented the right one).

And after reloading my Apache service it worked.

Hope this will save someone a bit of headache.

//F

phpteamer’s picture

Hi,

I'm using wamp server in my local system. I want to enable the clean URL , i followed the above instructions but it's not working for me.. It's saying 404 error..

noirita’s picture

Very Helpful.

creativelifeform’s picture

Yep, this worked for me, although I should point out that I had to do things a little differently.

I didn't have Apache installed before I installed WAMP, so the location of these files was a little different for me. Apache was inside of c:/wamp/bin/apache

Also, the document root inside of the conf/extra/httpd-vhosts.conf file has to be the same as the one in your httpd.conf file. That's probably obvious but it wasn't at 1am last night! Thanks again.

loudmu’s picture

worked like a charm

ashraf.hussain’s picture

Thanks a lot, it solved a big problem for me....

Note : the document root inside of the conf/extra/httpd-vhosts.conf file has to be the same as the one in your httpd.conf file

pentarex’s picture

The Solution for me was simpler.... in httpd.conf file I've just need to change AllowOverride None to All, then in drupal folder in htdocs named f.e. drupal6 the .htaccess must be changed. In the section

RewriteEngine ON

# If your site can be accessed both with and without the 'www.' prefix, you
# can use one of the following settings to redirect users to your preferred
# URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
#
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# adapt and uncomment the following:
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
#
# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/... will be redirected to http://example.com/...)
# uncomment and adapt the following:
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

# 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 /drupal6
#
# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
#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 ^(.*)$ index.php?q=$1 [L,QSA]

And Then everything was O.K.

dready2011’s picture

Thanks so much. After trying to get clean urls to work for HOURS and HOURs and reading dozens of pages, this finally solved it for me. THANKS!