By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,445 Members | 1,152 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,445 IT Pros & Developers. It's quick & easy.

Fixing case-sensitive file errors? Mac Dev to Unix host

P: n/a
Hello. I do most of my web dev work from a Mac (whose file system is
case-insensitive.) I upload my web pages and other files onto a
Unix-based host, which is case sensitive.

When I look at the errors that were generated on my web site, I find
that sometimes people are trying to access, for example, "file.exe",
when I uploaded it as "File.exe" with an uppercase letter.

Some of these pages and files have had mixed case for years and years,
and 99% (I'm guessing) of requests are proper requests with mixed case.
I now realize it's often best to use all lower case for filenames to
prevent any confusion. (Too late for that, mostly.)

Anyway, my question is, is there any unix trick that I can use (I'm NOT
a power unix user obviously) to automatically point a user who is
looking for "file.exe" (which doesn't exist) to "File.exe" which DOES
exist? I'd like to do this trick to a number of files that have this
mixed case problem.

(With some extra work, I suppose I could post two files for each file I
really wanted. One with the original mixed case file name, and one with
the all lower case version. But, I'm not nuts about this solution as,
on my Mac, I will then no longer be able to store an exact copy of my
web site in a folder as I now can do, since the Mac won't let me store
two files with the same name with differing case in the same folder.)

Anyone know of a unix trick to point a request for an all lower case
file to a file that exists with the same exact name but different case?

Thanks!
Apr 11 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
On 2007-04-11, Adam <ad**@smdopawmoa.comwrote:
Hello. I do most of my web dev work from a Mac (whose file system is
case-insensitive.) I upload my web pages and other files onto a
Unix-based host, which is case sensitive.

When I look at the errors that were generated on my web site, I find
that sometimes people are trying to access, for example, "file.exe",
when I uploaded it as "File.exe" with an uppercase letter.

Some of these pages and files have had mixed case for years and years,
and 99% (I'm guessing) of requests are proper requests with mixed case.
I now realize it's often best to use all lower case for filenames to
prevent any confusion. (Too late for that, mostly.)

Anyway, my question is, is there any unix trick that I can use (I'm NOT
a power unix user obviously) to automatically point a user who is
looking for "file.exe" (which doesn't exist) to "File.exe" which DOES
exist? I'd like to do this trick to a number of files that have this
mixed case problem.

(With some extra work, I suppose I could post two files for each file I
really wanted. One with the original mixed case file name, and one with
the all lower case version. But, I'm not nuts about this solution as,
on my Mac, I will then no longer be able to store an exact copy of my
web site in a folder as I now can do, since the Mac won't let me store
two files with the same name with differing case in the same folder.)

Anyone know of a unix trick to point a request for an all lower case
file to a file that exists with the same exact name but different case?
You could use symbolic links, I think you can configure Apache (assuming
that's what you're using) to follow symlinks when serving up files.

So you'd write a short script to symlink each file to a lowercase
version of itself, e.g. in Tcl:

foreach f [glob *.html] {
set l [string tolower $f]
if {![string equal $f $l]} {
exec ln -s $f $l
}
}

But why not just rename all the files on your local copy on the Mac once
and for all to have lower case everywhere, and then upload that?

I suppose people might have set up links and things to urls with mixed
case in your site and you don't want to break their links.

You could also try Apache's "mod_speling"

http://httpd.apache.org/docs/2.2/mod/mod_speling.html
Apr 11 '07 #2

P: n/a
Adam <ad**@smdopawmoa.comwrote:
Anyway, my question is, is there any unix trick that I can use (I'm NOT
a power unix user obviously) to automatically point a user who is
looking for "file.exe" (which doesn't exist) to "File.exe" which DOES
exist? I'd like to do this trick to a number of files that have this
mixed case problem.
The easiest thing is to do it the other way round. Fix your filenames and
then point anyone looking for "File.exe" to "file.exe". Just add this to
your Apache configuration:

rewriteEngine on
rewriteMap lowercase int:tolower
rewriteCond $1 [A-Z]
rewriteRule ^/(.*)$ /${lowercase:$1} [R=301,L]

This is better than just ignoring the case because the 301 status code will
make sure search engines only store the lowercased version instead of
thinking you have a lot of similar pages differing only in the case of the
URLs.
Apr 13 '07 #3

P: n/a
Thanks to all (Ben, Duncan) for your great replies. Much appreciated.

But, I think BOTH of the solutions aren't applicable to me. I bounced
the first of the ideas off my web host provider (the mod_spelling) but
the response was that my site is hosted on a server that hosts many
other sites (no doubt, why it's relatively cheap!) and as such I can
NOT customize the server. I knew Unix had to have a sneaky way to fix
things, but it appears, so far, I can't use the great ideas presented.

Taking a related route, though...I'm learning about symbolic (soft)
links. Do you think this is a viable route to explore? The thing of it
is that I have a known finite number of affected files (say, 10). So, I
may have the occasional requests for up to 10 fixed named files that
are all in lower case. Can I create a symbolic link that "points" a
request for "file.exe" (which does NOT exist) into a request for
"File.exe", which does? I'm writing this before I check out exactly how
to create a symbolic link (like I said, Unix is not my forte), but I'm
hoping I can just fixedly create 10 symbolic links for the 10 known
files that have the mixed case problem and upload these symbolic links
like they were any other type of file to my web host.

Thanks again for your thoughts...

In article <Xn*************************@127.0.0.1>, Duncan Booth
<du**********@invalid.invalidwrote:
Adam <ad**@smdopawmoa.comwrote:
Anyway, my question is, is there any unix trick that I can use (I'm NOT
a power unix user obviously) to automatically point a user who is
looking for "file.exe" (which doesn't exist) to "File.exe" which DOES
exist? I'd like to do this trick to a number of files that have this
mixed case problem.

The easiest thing is to do it the other way round. Fix your filenames and
then point anyone looking for "File.exe" to "file.exe". Just add this to
your Apache configuration:

rewriteEngine on
rewriteMap lowercase int:tolower
rewriteCond $1 [A-Z]
rewriteRule ^/(.*)$ /${lowercase:$1} [R=301,L]

This is better than just ignoring the case because the 301 status code will
make sure search engines only store the lowercased version instead of
thinking you have a lot of similar pages differing only in the case of the
URLs.
Apr 14 '07 #4

P: n/a
Adam <ad**@smdopawmoa.comwrote:
Taking a related route, though...I'm learning about symbolic (soft)
links. Do you think this is a viable route to explore?
You might use it as a last resort, but it would be much better to create an
..htaccess file that configures proper redirect responses for the incorrect
URLs. Redirect responses don't create multiple URLs that must be treated as
distinct by browsers, caches, etc., even though they actually return the
same file.
--
Darin McGrew, mc****@stanfordalumni.org, http://www.rahul.net/mcgrew/
Web Design Group, da***@htmlhelp.com, http://www.HTMLHelp.com/

"How long is this Beta guy going to keep testing our stuff?"
Apr 14 '07 #5

P: n/a

Perfect! Exactly what I wanted. I looked up how to do a Redirect in an
..htaccess, tried it, works like a charm. THANKS!
In article <ev**********@blue.rahul.net>, Darin McGrew
<mc****@stanfordalumni.orgwrote:
Adam <ad**@smdopawmoa.comwrote:
Taking a related route, though...I'm learning about symbolic (soft)
links. Do you think this is a viable route to explore?

You might use it as a last resort, but it would be much better to create an
.htaccess file that configures proper redirect responses for the incorrect
URLs. Redirect responses don't create multiple URLs that must be treated as
distinct by browsers, caches, etc., even though they actually return the
same file.
Apr 14 '07 #6

P: n/a
On 2007-04-14, Adam <ad**@smdopawmoa.comwrote:
Thanks to all (Ben, Duncan) for your great replies. Much appreciated.

But, I think BOTH of the solutions aren't applicable to me. I bounced
the first of the ideas off my web host provider (the mod_spelling) but
the response was that my site is hosted on a server that hosts many
other sites (no doubt, why it's relatively cheap!) and as such I can
NOT customize the server. I knew Unix had to have a sneaky way to fix
things, but it appears, so far, I can't use the great ideas presented.

Taking a related route, though...I'm learning about symbolic (soft)
links. Do you think this is a viable route to explore?
It also requires server configuration-- you need to tell the server to
follow symlinks. I don't think they usually do by default.

Your web host provider might have mentioned that you can do some server
configuration in the form of .htaccess files (that's what they're for),
since from your other post it appears you can. Given that you can use
..htaccess, Duncan's rewrite solution is better than the symlinks anyway.
Apr 14 '07 #7

P: n/a
Adam wrote:
Hello. I do most of my web dev work from a Mac (whose file system is
case-insensitive.) I upload my web pages and other files onto a
Unix-based host, which is case sensitive.

When I look at the errors that were generated on my web site, I find
that sometimes people are trying to access, for example, "file.exe",
when I uploaded it as "File.exe" with an uppercase letter.

Some of these pages and files have had mixed case for years and years,
and 99% (I'm guessing) of requests are proper requests with mixed case.
I now realize it's often best to use all lower case for filenames to
prevent any confusion. (Too late for that, mostly.)

Anyway, my question is, is there any unix trick that I can use (I'm NOT
a power unix user obviously) to automatically point a user who is
looking for "file.exe" (which doesn't exist) to "File.exe" which DOES
exist? I'd like to do this trick to a number of files that have this
mixed case problem.

(With some extra work, I suppose I could post two files for each file I
really wanted. One with the original mixed case file name, and one with
the all lower case version. But, I'm not nuts about this solution as,
on my Mac, I will then no longer be able to store an exact copy of my
web site in a folder as I now can do, since the Mac won't let me store
two files with the same name with differing case in the same folder.)

Anyone know of a unix trick to point a request for an all lower case
file to a file that exists with the same exact name but different case?

Thanks!
There is nothing really wrong with mixed-case file names. I do it all
the time. Go to my home page, scroll to the bottom, and select "Index
of HTML Files". You will see several files and even a few directories
with mixed-case names.

The problem is that, within your Web site, you must create links that
refer to all the files consistent with their mixed-case names. Thus, if
a file is "File.exe" (per your example), you must then use
<a href="File.exe">
and not
<a href="file.exe">

The use of soft links on your server will help. However, you should
consider that only a temporary solution until you correct your link
references. I use a soft link when I move a file from one directory to
another, to help visitors find the Web page at its old location. I then
warn those visitors that the page has moved and that they should update
their bookmarks. About 3 months later, I remove the soft link and the
warning.

--

David E. Ross
<http://www.rossde.com/>.

Anyone who thinks government owns a monopoly on inefficient, obstructive
bureaucracy has obviously never worked for a large corporation. 1997
Apr 14 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.