Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make a file look like it is in the root directory on server
    primarykey
    data
    text
    <p>I have separate domains pointing to separate document roots on a dedicated box</p> <p>I want to grant FTP access to a subfolder ftp-upload below this document root.</p> <p>The proper FTP configuration is not part of this question</p> <p>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</p> <p>The .htaccess file is in the document root</p> <p>I've tried a few things but they don't seem to work.</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; 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] &lt;/IfModule&gt; </code></pre> <p>I've also tried </p> <pre><code>RewriteCond %{DOCUMENT_ROOT}/ftp-upload/${REQUEST_FILENAME} -f </code></pre> <p>and</p> <pre><code>RewriteCond %{DOCUMENT_ROOT}/ftp-upload%{REQUEST_URI} -f </code></pre> <p>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.</p> <p>UPDATE: It looks like the thing DOES work, when it wants...</p> <p>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</p> <p>If I type in domain.com/ftp-upload/ I get a directory listing including test.txt</p> <p>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...</p> <p>My head exploded... any ideas?</p> <p>SOLVED another way answers here did not work on my server.</p> <p>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..</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload