Htaccess and file/directory redirection


I have a site, , that has some ‘file’ URIs such as

and some ‘directory’ URIs such as

Since Radiant is case sensitive, I would expect visiting

to 301 redirect to

as normally happens with Apache.

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

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:


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,
may need something else, perhaps individual rewrite rules for those
directories. Are you expecting directory listings or opening an index
(index.php or index.html or something) in those?

From the Apache 2.0 docs:


The solution to this subtle problem is to let the server add the
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
but would go wrong when any images are included into this page with
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
of their homedir. But notice that this creates some processing overhead.

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

Sean C.