Sunday, January 18, 2009

My Quest to Enable Clean URLs

I've spent the weekend with a series of computer problems I didn't expect. (I never expect computer problems; I don't know why not.) Saturday seemed like the right time to install Drupal in my root directory on It was working well on localhost, and in a subdirectory on, so I thought it was ready for prime time. (Silly, heedless me!) Turns out it wasn't, and something untoward happened to my old Web page backups. Eventually, I got back to its accustomed state of neglect. (That problem involved a lot of futile chmod activity.)

Meanwhile, the Drupal problem was that I couldn't enable "Clean URLs" when I installed Drupal in the root directory. "Clean URLs" rewrites dynamically generated URLs so they don't have the little "?q=" thing that tells us the page was generated from a php script, and tells search engines it's not a "real" web page, so don't index it. If you want people to find you using search engines, you really want "Clean URLs."

OK, the Clean URLs manual page from tells us there are two reasons Drupal installation might fail to enable "Clean URLs:" the Apache server doesn't have mod_rewrite enabled, and/or the .htaccess file in the root directory is missing or wrongly constructed. Now, because Clean URLs worked in the subdirectory, I knew that my provider's server had the rewrite_module enabled, but I checked anyway:

[rclayton@w6 ~]$ apachectl -M
httpd: Could not reliably determine the server's fully qualified domain name, using for ServerName
Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)

...lotsa modules...

 imagemap_module (shared)
 actions_module (shared)
 speling_module (shared)
 userdir_module (shared)
 alias_module (shared)
 rewrite_module (shared)
Syntax OK
[rclayton@w6 ~]$

There it is, at the end. OK, I read through the .htaccess file from start to finish, and I tried commenting and uncommenting a couple of potential lines that might make a difference. They didn't. I spent some time Googling for other people's observations on this phenomenon; those who solved it used one of these two solutions.

Sigh. At last, I came across a bug report: Clean URLs test fails with JS enabled; Passes with JS disabled and clicking 'Test Clean URLs' link. This is not for Drupal 6, which I'm running, but one commenter observes:

For what it's worth, all my clean url problems were solved by deleting an errant "Admin" folder in my root directory (a remnant of some old installation of something or other, but no longer needed).

Bingo! My service provider uses to send us to our stats, phpmyadmin, and other utilities. Since Drupal uses for many things including "Clean URL's," it's not ever going to work. The bug report closes with:

The clean urls test uses an url like "http://yoursite/admin/clean-url-test" so if you have an "admin" folder in your drupal install, that path will not be handled by Drupal. Going to mark this as 'by design.'

So, it's up to me to find a solution. There are many possibilities, and I'm still reading all about them. I could put my Drupal installation at and alias or redirect to the drupal directory....Well, it's a lot to read about. Here are some resources that seemed helpful.

No comments: