Drupal 'Clean URL's and mod_rewrites' grrrrh

Some of you will know why I've put my old Filemaker blog to bed....ok I'll remind you....Google wouldn't index my blog entries, cos Google couldn't follow Filemaker URL's.

I'm now using Drupal and guess what, Google hasn't indexed these blog entries either! Oh good.

I'm wondering if this is to do with Drupal URL's that look a bit like this

http://www.jonathansblog.net/?q=node/view/20/
Google doesn't seem to like following links with '?' or '=' in the URL. I did a bit of searching on the net for people who might have experienced the same, they have! Luckily, Drupal supports 'clean url's' which turn this.....
http://www.jonathansblog.net/?q=node/view/20/
into
http://www.jonathansblog.net/node/view/20/
How neat is that!?

It took a bit of doing though, for anyone who needs to do this, here's how....

1. In Apache's conf/httpd.conf do the following:

uncomment LoadModule rewrite_module modules/mod_rewrite.so
uncomment AddModule mod_rewrite.c
for the drupal site, in the directory node, set AllowOverride All

2. In root directory of drupal, edit .htaccess:

verify RewriteEngine on
set RewriteBase if required

3. In Drupal navigate to /administer/configuration and set Clean URLs to Enabled.

Fingers crossed that Google indexes my content. I nearly got to the point of starting my blog in Moveable Type, I'm so glad I didn't in the end, I do like Drupal. Also, people have described Moveble Type as the Windows version of blog software!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Povl Koch

Thanks, now it works for me too!

Dave

Worked for me with a couple of hitches:



1. For Apache2 on Windows, there is no AddModule mod_rewrite.c line, so forget it.

2. Add the AllowOverride All (misspelled above) to a Directory inside your site config like this:

<Directory /path/to/your/drupal/dir>
  AllowOverride All
</Directory>

PS> Found this page on Google, so I guess it works, huh?


www.waterwire.com

Jonathan Furness

Excellent - thanks for your comments.... that's really useful to know. As you may have guess already, much of my development is done on Mac OSX.

Farhan Ahmad

Hi,
Clean URLs weren't working for me either. I went through what you have suggested and a similar article on drupal.org's forum but it still didn't work. After looking through my httpd.conf I noticed the following entry:

<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.

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

Jonathan

Thanks Fahran, much appreciated.... I'll check out your site....!

Farhan Ahmad

Sorry, the previous link pointed to the wrong post on drupal.org. This should be the correct on.

- Farhan

Jonathan

no worries :-)

MagnusB

Putting this in .httpd.config will also work:

Options FollowSymLinks
AllowOverride All
RewriteEngine on

Do not remove the default:

Options SymLinksIfOwnerMatch
AllowOverride None

MagnusB

Sorry, the above should be:

Putting this in the main .httpd.config will also work:

<Directory /path_to/site>
   Options FollowSymLinks
   AllowOverride All
   RewriteEngine on
</Directory>

Do not remove the default but instead add the above block below the default block:

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

i wish it works for me

I tried everything that you posted except making changes in the .htaccess (RewriteBase). When I did my change, I start my apache1.3 and try to get into the admin and settings to Enable the clean url radiobox. but it tuned me that you need the ModRewrite with ur admin....

what i didn't get is

Options FollowSymLinks
AllowOverride All
RewriteEngine on

the /path/to your/dir i couldn't get it . my drupal is sitting in the htdocs of apache. Meaning C:/program files/apache group/apache/htdocs/drupal.
plz correct me..

i wish it works for me

I tried everything that you posted except making changes in the .htaccess (RewriteBase). When I did my change, I start my apache1.3 and try to get into the admin and settings to Enable the clean url radiobox. but it tuned me that you need the ModRewrite with ur admin....

what i didn't get is
Directory
Directory /path_to/site
Options FollowSymLinks
AllowOverride All
RewriteEngine on
Directory

the /path/to your/dir i couldn't get it . my drupal is sitting in the htdocs of apache. Meaning C:/program files/apache group/apache/htdocs/drupal.
plz correct me..

cheers

"for the drupal site, in the directory node, set AllowOverride All" what is please a directory node???

Jonathan

think this refers to the directory path where Drupal is installed and from which nodes (Drupal articles) will be referenced from. So in terms of AllowOverride All, make sure this is applicable to the Drupal directory in your .htaccess file.

Imran

None working for my site :(

Rog

Clean URLs aren't needed for Google to index, not do they give you higher rankings, that's a myth. They only use words in URLs as keywords if they aren't already present either on the page or in links to your site.

Google can index get URLs (?q= type URLs) just fine, you'll find many of them from searches. I've never used URL rewriting, but my blog pages are well ranked (using Wordpress, URLs come out like http://example.com/index.php?p=365).

If your site wasn't being indexed, it's for another reason.

Read up on how Google indexes sites, they list it all openly in their documentation, there's no voodoo or deep dark mysteries about it, all of their really difficult stuff is in rankings, not indexing.

Jonathan

Hi Rog

Thanks for your comment. I think the post, back in March '04, came as a result of my work building a blogging engine using Filemaker. Back then, Filemaker URLs really were 'bad' and no indexable, for whatever reason. I spent lots of time investigating at the time, so I moved over to Drupal.

I suppose the same anxiety pursued this move, hence the blog post. However, I'm glad I looked at the 'clean URL' technology because, as you say, pages are better indexed because of words in the URL. Are you sure words in the URL aren't given more favour in Google searches? How can we test / prove this?

Jonathan

batwing

Hello there!

I wonder if you know any way to set up the clean urls in drupal (and not only to turn it on). I mean the way you can do in wordpress. I'm thinking about switching to drupal, but know, that quite alot hits on my website are from static referers (infos on forums and other pages) and I don't want these referers to lead nowhere, so I was hoping to keep my urls as they are now (like http://batwing.pl/YYYY/MM/title-of-an-entry and - if it is possible - for tags and categories as well).

Drupal seems to be much more powerfull engine than wp, but it has few small problems like this one, that make me hesitate on switching.

Thanks
batwing

ozer

I have just adjusted as you said. But my problem continue. The choice Enable clean url is still grey and I can not activate it. I set drupal wwwroot I mean main directory but I can not activate clean url. Please help. Thanks.
the site: http://www.uniyolu.com/
mail: uniyolu@hotmail.com

nabil

listen niggaz

do this maybe with all of the above:

You should uncomment '#RewriteBase /drupal' in the .htaccess file and remove 'drupal'. It should look like this:
RewriteBase /

Next add the following code snippet to your settings.php file located at site/default/settings.php.
$conf['clean_url'] = 1;

nabil

on second though dont include anything in settings.php

this RewriteBase /drupal should be like this everywhere in .htaccess file.

note above RewriteBase /drupal indicates my directory where drupal folder is residing

Nico

Many thanks for the tip !

coonweb

Here is a video to explane how to get clean urls on Drupal website!

http://www.drupaldude.com/content/clean-urls-need-htaccess-file

Have a nice day! ;)

Post new comment

m
x
x
q
Enter the code without spaces and pay attention to upper/lower case.
Syndicate content