This isn't really a question. It's more a "Clean URLs didn't work out of the box for me, but this is how I fixed it" document, in case anyone might find it useful.

So I'm assuming that, in this case, you have pretty much complete control over your HTTP server, Apache. I'm using Apache2 as an example, with the configuration that's given by Debian Sarge.

The first thing: make sure that your .htaccess file is actually being recognized by the server. By default in Debian, the system ignores all .htaccess files.

I changed this by editing the file "/etc/apache2/sites-enabled/default" and adding:


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

where cs445 is the subdirectory where my Drupal lives in.

The most important line is the "AllowOverride All" line, because that permits the .htaccess file to modify the way the server works. (I know that putting "all" is kind of risky, so if anyone can suggest something better, please do).

The file you edit is different under Fedora and other distros, but the general point is that you have to change the AllowOverride directive in the directory where Drupal lives.

That will probably fix most people's memory and PHP config problems as well.

While you're at it, check that the rewrite module is being loaded. Use the a2enmod command in Debian to enable the "rewrite" module. I think it's enabled by default, but these things are prone to change. In Fedora and other distributions, the line to add rewrite support should look something like (but probably not exactly): LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so. That should appear somewhere in your configuration files.

When you're done configuring everything, restart the Apache web server.

The second thing to do is to check that your .htaccess file is actually there in the directory you put Drupal in. Because it's a hidden file, if you copied stuff using a normal "cp", it might not have been picked up with everything else. If it's not there, copy it manually.

Now that that's all done, open up the .htaccess file and look at it. Check that under "", you have the correct RewriteBase. In my case, because Drupal is under /var/www/cs445, my rewrite base is /cs445.

Once you got that all down, try it out. Turn on Clean URLs from the Administration page. If you get an error, hit the back button immediately and turn them off again (or else you'll have to do the Unsetting of clean URLs over here.

So the summary of steps is:

1) Set "AllowOverride All" in the directory where Drupal lives.
2) Make sure rewrite module in Apache is enabled (a2enmod in Debian; LoadModule rewrite_module /path/to/mod_rewrite.so in other Apache configs)
3) Make sure .htaccess exists.
4) Set the correct RewriteBase
5) Restart Apache
6) Try out Clean URLs

I don't know how useful this post is... maybe no one has this problem anymore. However, enabling clean URLs always comes to bite me in the butt whenever I install Drupal somewhere, so I figured that even if no one else needs this, if it's posted up here, it means that I can find it later. :)

Comments

irwin’s picture

Part of the config file after "I changed this by editing the file "/etc/apache2/sites-enabled/default" and adding:" was cut out.

It should look like:

<Directory /var/www/cs445>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  allow from all
</Directory>

If someone could edit that for me I would appreciate it. Thanks!

-- Irwin

i100yanov’s picture

I would like to add, that in Slackware 10.0, the file to be edited is /etc/apache/httpd.conf. When adding:

<Directory /the/path/where/drupal/resides>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride All
 Order allow,deny
 allow from all
</Directory>

just after the default settings for the /var/www/htdocs directory, everything works as expected.

Thanks, irwin for pointing me at the right direction!

thebitguru’s picture

Hi,
I tried what was sugggested but Clean URLs still did not work for me. After looking through my httpd.conf I noticed the following entry (in addition to the directory specific one):

<Directory />
Options SymLinksIfOwnerMatch
AllowOverride None
</Directory>

This directory config block was causing the problem even though I had AllowOverride set to All in drupal's directory config block. Now that I think about it, this behavior _does_ make sense. Anyways, Changing the "AllowOverride None" to "AllowOverride All" in this block brought everything back to normal. Security-wise this is probably not the best thing to do but right now my goal was to get this to work.

Thanks!
http://www.farhan-ahmad.net

MichaleR’s picture

I habitually put a leading / on my path alias. This breaks it. If you've followed the other recommendations here and still are having problems, remove leading and trailing slashes.

jsgreenawalt’s picture

Your post has put an end to hours of frustration :-)