I am trying to make an upload script, and I would like to make the same file/page to be shown on all empty directories (and filled ones too). This file/page would be shown and would act as any other file/page, but it wouldn't actually be there. I thought that the .htaccess file might be able to do this.
An example would be: When you create a directory, the file you are uploading with would be available for you to use to upload to your new directory, but it wouldn't be there for you to accidentally overwrite that same file while uploading. This would also save space, depending on how many directories you have to make.
If you make copies of the file every time you make a directory, and you make a billion directories, you make a billion files... That's a lot even if it's 1 kilobyte per file!
My strategy would take 1 file and make it universal to the sub-directories without actually taking up any more space than the one upload file would.
By the way, I am using a standard GoDaddy hosted Linux server. It has PHP 5.3 on it.
I would want all of the directories below this .htaccess file to have this 'rule', but not the directory that the .htaccess file is in.
To have directory paths (not ending with a file name) all display the same index page, for example: http://www.example.com/directory1/
or http://www.example.com/directory2
would each load http://www.example.com/defaultindex.html
, try something like the following:
RewriteRule ^[^.]+$ /defaultindex.html [L]
This says to match any path that does not include a dot (and thus does not end in .html, .jpg, etc.) and rewrite it to the file example.com/defaultindex.html (this file must exist in this one location).
That's a very general rule which will obviously match a lot of things, but that seems to be what you want. You'll need to add RewriteConds or make the rule more specific if you need to exclude any specific directory paths, but this should be a starting point.