Just don't use relative URIs in the javascript contained in the files in the subfolders.
e.g.
If you go to the page http://www.yoursite.com/test/sub.htm.
In the sub.htm javascript you force the location like this.
'../index.htm?http://www.yoursite.com/test/sub.htm'
(where index.htm is your frameset page)
You just have to make sure your location.search code is set up to handle the full URI.
You could also use javascript to get the URI of the subpage an store it in a variable to use. That way the site will be portable and you won't have to change the static URIs in the javascript for the subpages.
So in the javascript of your subpage, you could have something like this. (depending on the method you use to force frames).
PHP Code:
<script type="text/javascript">
<!--
x=location;
var correct_frame = 0 + (parent.menu ? 1 : 0);
if (parent.location.href == self.location.href || !correct_frame)
window.location.href = '../index.htm?' + x;
//-->
</script>
That example was part of a force frame for a 3 frame frameset.
If you're posting a link somewhere of one of your subpages or any other page besides the default frame, you would want to put the full uri after the question mark anyways.
Now if you don't like having the full URI of the subpage, you can make the javascript in your frameset page better.
for example, in the sub.htm page referred to above, you could use window.location.href='../index.htm?sub.htm';
Then you would have to setup the javascript in your frameset page to know that if sub.htm comes after the question mark, "test/sub.htm" should be loaded in the frame.
Doing it that way would still allow the site to be portable and allow you to have whatever alias you want for each sub page.
e.g index.htm?this_is_cool could take the vistor to some subfolder or whatever.