Well, it _is_ tricky in the details (i.e. where the &Devil; lives).
Part of the problem is that server software varies, and so do the
settings, and a typical web server admin doesn't even bother telling
the poor web authors what the settings are. So it's quite possible
that even if you do things by the book, they won't work because the
server admin disabled a few features. As far as I know, distributions
of Apache and similar software have disabled more and more features by
default. At the extreme, a web author cannot used .htaccess at all,
except perhaps by paying some extra money to the ISP.
You might think, after reading a nice tutorialish document like
http://corz.org/serv/tricks/htaccess2.php
that you could achieve your goal simply by adding
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)_(.*)$ $1/$2
to your .htaccess file. (I'm assuming that "to change folder/filename
to folder_filename" means "to make folder_filename work as an alias
for folder/filename". If you really meant the opposite, you would just
make the obvious modification.)
However, the odds are that you get just some nasty 5xx error page,
because the server settings won't let you use the rewrite engine.
The next attempt is to use something like
RedirectMatch permanent /~jkorpela/test/(.*)_(.*)
http://www.cs.tut.fi/~jkorpela/test/$1/$2
As you may guess, I tested this in my test directory only, as some of
my URLs may contain "_", which might cause unpleasant surprises. I
hope you can see how to modify the command. Note that the third
argument must be a relative URL and the fourth argument must be an
absolute URL! The rest is rather easy if you know the basics of
regular expressions: .* matches any string, parentheses are essential
(as only parenthesized expressions count in the replacement
expression), and $1 and $2 indicate the strings that have matched the
1st and 2nd parenthetic expression.
Beware that this is less efficient than the rewrite engine. This
approach means that when a client requests for
http://www.cs.tut.fi/~jkorpela/test/foo_bar
then the server processes it and tells the client that the resource
has been permanently moved to
http://www.cs.tut.fi/~jkorpela/test/foo/bar
and then the client requests for that. So there's a rather foolish
HTTP transaction here. But this approach typically works if anything
useful works in .htaccess according to your server admin settings.