I have separate domains pointing to separate document roots on a dedicated box
I want to grant FTP access to a subfolder ftp-upload below this document root.
The proper FTP configuration is not part of this question
If a granted person uploads a file to document_root/ftp-upload, this file should be accessible via domain.com/file rather than domain.com/ftp-upload/file
The .htaccess file is in the document root
I've tried a few things but they don't seem to work.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
## check if the file exists in subfolder
## ...and if found, stop and display it
RewriteCond %{DOCUMENT_ROOT}/ftp-upload/$1 -f [OR]
RewriteCond %{DOCUMENT_ROOT}/ftp-upload/$1 -d
RewriteCond $1 !^$
RewriteRule (.*) %{DOCUMENT_ROOT}/ftp-upload/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css|assets|ftp-upload)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
I've also tried
RewriteCond %{DOCUMENT_ROOT}/ftp-upload/${REQUEST_FILENAME} -f
and
RewriteCond %{DOCUMENT_ROOT}/ftp-upload%{REQUEST_URI} -f
It's a work in progress so this will not be the final solution, but this feature is being requested a lot. And I would rather not give them access to the document root if possible.
UPDATE: It looks like the thing DOES work, when it wants...
If I type in domain.com/test.txt (which exists in the ftp-upload directory only) the request goes to domain.com/index.php/test.txt and I am served the homepage
If I type in domain.com/ftp-upload/ I get a directory listing including test.txt
If I click on test.txt I get the file contents (which is "it works!"). If I then type in domain.com/test.txt I get the file contents displayed again...
My head exploded... any ideas?
SOLVED another way answers here did not work on my server.
The CMS I built now has another user group 'SEO Optimization' and an upload section. Under that section the user can select which of his assigned locations they want to upload the file to. The website index.php (controller/router) will serve the requested file if it exists in the upload folder. No .htaccess edits as my server was acting funky..