Wednesday, October 26, 2005

 

Helping Drupal (with url aliases turned on) - and htaccess - ignore a subfolder

Not the easiest. Found a page on the Drupal site talking about how to do this, but it doesn't work. *sigh* This is what I want to do...

I have this blog sitting at www.burningdog.co.za/blog and a fresh Drupal install at www.burnindog.co.za. I've turned url aliasing on which means *everything* at burningdog.co.za is passed through Drupal...including my /blog folder, which is then process and Drupal says "page not found." So I need to reconfigure my .htaccess file for it to still work with the url aliasing in Drupal, but to ignore that when I hit the /blog folder.

This is the code that finally worked:

  RewriteEngine on

# ignore the blog subfolder
RewriteCond %{REQUEST_URI} !blog/
RewriteRule ^(.*)$ $1
DirectoryIndex index.html [L]
I'm waiting for my Drupal login details to arrive and then I'll post it on their site. But for now, I'll continue reading Harry Potter. Btw, I found that unless that last line (with the index.html) was added in, it wouldn't work. As long as this is your default file then you're fine. Otherwise change it to index.php or whatever you need it to be.

Other links I came across:

The official mod_rewrite site.
A bit friendlier version, also at the apache site.

Although, if you ask me, the code looks like frikking assembler. I spent the best part of an hour and a half trying to get the exact right syntax. And there's no way of debugging the code either - it either works or it doesn't...no wonder it's voodoo!

[UPDATE]: the above code worked, all right, but it broke my Drupal comments. Have NO idea why! So I disabled it and went hunting around for code that does. Here it is:

RewriteEngine on

# ignore the blog subfolder
RewriteRule /blog/ blog/index.html
DirectoryIndex index.html [L]
The last line needs to be there for the same reasons as above. I got most of the code from The Art of Web and just needed a minor rewrite.

Technorati Tags: , , ,


|



<< Home

This page is powered by Blogger. Isn't yours?