Htaccess and file/directory redirection

Hi,

I have a site, http://uk.tug.org/ , that has some ‘file’ URIs such as

http://uk.tug.org/activities

and some ‘directory’ URIs such as

http://uk.tug.org/Activities/
http://uk.tug.org/Baskerville/

Since Radiant is case sensitive, I would expect visiting

http://uk.tug.org/Activities

to 301 redirect to

http://uk.tug.org/Activities/

as normally happens with Apache.

However, this is not working with the default Radiant .htaccess in
place.

I have asked my host’s support team if there was something in their
server level apache configuration that would alter things, but there
isn’t - if I move the .htaccess to .htaccess.old then the directory
behavior works as normal.

I am totally stumped :slight_smile:


Regards,
Dave

You shouldn’t have a problem if the URL points directly to a file; the
built-in rewrite rules take care of that. If it points to a directory,
you
may need something else, perhaps individual rewrite rules for those
directories. Are you expecting directory listings or opening an index
page
(index.php or index.html or something) in those?

From the Apache 2.0 docs:

Solution:

The solution to this subtle problem is to let the server add the
trailing
slash automatically. To do this correctly we have to use an external
redirect, so the browser correctly requests subsequent images etc. If we
only did a internal rewrite, this would only work for the directory
page,
but would go wrong when any images are included into this page with
relative
URLs, because the browser would request an in-lined object. For
instance, a
request for image.gif in /~quux/foo/index.html would become
/~quux/image.gifwithout the external redirect!

So, to do this trick we write:

RewriteEngine on
RewriteBase /~quux/
RewriteRule ^foo*$* foo*/* [R]

The crazy and lazy can even do the following in the top-level .htaccess
file
of their homedir. But notice that this creates some processing overhead.

RewriteEngine on
RewriteBase /~quux/
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ $1*/* [R]

Sean C.
seancribbs.com