Ok, maybe I missed this somewhere, but I see all of these Drupal websites and the urls are nice and tidy with /node/add/forum/1 instead of /mod=forum?add=1 or somesuch... So how are people doing this? I'm finding that since I switched to Drupal my blog entries don't get picked up by Google and I suspect its due to the PHP param passing. But I can do searches on Google for topics here on www.drupal.org and can find them no problem but the links are to the nice pretty /'s with no .php?bar=foo type coding.

Is there a switch to turn this on? Some .htaccess trick? a module or hack that does this?

FWIW: My production site is running Drupal 4.1 but I have a test site running CVS from last night (May 4).

Comments

Anonymous’s picture

Doesn't Apache have a URL rewrite mod.... maybe that is what people are using. I'm no expert at it though, so you'd have to look up the documentation to figure out how...

al’s picture

Go to your site config admin page.
Select CleanURL support enabled.
Hit save.

The .htaccess file shipped with Drupal CVS doesn't need modifying. It works straight out of the box. This is one of the most visible improvements from 4.1 to CVS (the admin screens are also a lot nicer, but most of your users won't ever see that).

Note that in order for it to work, you'll need to have the mod_rewrite module enabled in Apache. To see if this is the case, you can create a php page which just calls the function phpinfo(). Apache modules are listed in there somewhere about halfway down.

It's also possible to get clean URLs working under IIS, but I don't have the details. Please post to the development mailing list if you want to do that, where someone else will be able to enlighten you.

Mike@frazierhome.net’s picture

Ok, I turned on the clean url and I see thats what its trying to use now, but I get page not found errors. .htaccess is straight from the CVS I pulled down. I also did the phpinfo() and can see mod_rewrite is a loaded Apache Module.

I did put a simple rewrite rule in that I use on another webhost and that didn't work either, so I'm not sure rewrite is working and thats probably the issue.

Anonymous’s picture

I tried to turn on clean URLs support on my Drupal (CVS) website today, but whenever I click on a link, I got a 404 error because the /node/add URLs don't really exist, and don't seem to be "transformed" into the real URLs, like /?q=node/add

Anonymous’s picture

You just need to set
"AllowOverride All" for your Drupal directory in the apache configuration file...

Now I'm having the "theme" problem!

Anonymous’s picture

I'm using a customized "interlaced", and my problem was solved by applying recent changes made to this theme as shown in the CVS repository.

David Hull’s picture

Another wrinkle:

I'm running Drupal in a subdirectory of my public_html directory.
Since Drupal's index.php is not at DocumentRoot in my setup, I had
to add

  RewriteBase /~david/drupal-4.2.0

in Drupal's .htaccess file (e.g.,
~david/public_html/drupal-4.2.0/.htaccess).

duztin’s picture

Did you ever fix the theme problem? When I turn on clean url's the theme gets all messed up.

desertsage01’s picture

Your trick worked like a charm. I'm running Apache2 and only had to change two lines of code in the httpd.conf file.

Uncomment:
LoadModule rewrite_module modules/mod_rewrite.so

Right below "Options Indexes FollowSymLinks"
Change:
AllowOverride None
to
AllowOverride All

With 4.4.1 everything works great! Nice clean URLs.

Now to just figure out module scripting...

arsart’s picture

sorry, i can`t find in configuration - support CleanURLs
were it is?

thanx

ax’s picture

http://yoursite.com/?q=admin/system , last entry in "General settings"

arsart’s picture

hmm...sorry, but in my "General setting" last entry is "Default front page"
It`s very strange but
nowhere else in my admin settings I can`t find smth about cleanUrls:(

Using Drupal 4.1.

p.s.
May be this is a module?

killes@www.drop.org’s picture

Clean URLs are only available in CVS. Try the 4.2 release candidate.

aldon@deanspace.org’s picture

If someone can tell me how to get Clean URLs working under IIS, I would love to hear it.

Aldon

moshe weitzman’s picture

I tried ... requires someone to write an ISAPI filter.

kennysto’s picture

The .htaccess file shipped with Drupal CVS doesn't need modifying. It works straight out of the box.

except when your drupal files are in a sub directory

droopy’s picture

I have the CVS with mod_rewrite enabled and .htaccess untouched. I have enabled clean urls. The site works until a node is accessed - the text appears and all the functionality is there, but the theme has not loaded with it.