Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Facts as I understand them (please correct me if wrong)</p> <ul> <li>you have seperate domains pointing to separate document roots</li> <li>you want to grant FTP access to a subfolder <code>ftp-upload</code> below this document root.</li> <li>the proper FTP configuration is not part of this question</li> <li>if a granted person uploads a file to <code>document_root/ftp-upload</code>, this file should be accessible via <code>domain.com/file</code> rather than <code>domain.com/ftp-upload/file</code></li> <li>the .htaccess file is in the document root</li> </ul> <p>For the above facts here's a working <code>.htaccess</code> file. Please note the folder name I used is <code>ftp-upload</code>, you've used several different versions in your question (<code>ftp-upload</code>, <code>ftp_upload</code>, <code>ftpupload</code>) make sure, this is consistent in your configuration</p> <p><strong>.htaccess in your domains document root folder</strong></p> <pre><code>RewriteEngine On RewriteBase / RewriteCond %{DOCUMENT_ROOT}/ftp-upload%{REQUEST_URI} -f [OR] RewriteCond %{DOCUMENT_ROOT}/ftp-upload%{REQUEST_URI} -d RewriteRule ^(.*)$ ftp-upload/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^(index\.php|images|robots\.txt|css|assets) RewriteRule ^(.*)$ index.php/$1 [L] </code></pre> <p>What I do, is to check for the existence of the requested file in the subfolder <code>/ftp-upload</code>.</p> <p>The tricky thing was that <code>RewriteCond file -f</code> requires a full path. That's why you would usually test against <code>%{REQUEST_FILENAME}%</code> If this condition is true (file exists) simply rewrite the request to <code>ftp-upload/filename</code></p> <p>This will also work for subfolders within <code>ftp-folder</code> e.g. folder <code>ftp-folder/test/image.png</code> will be accessible as <code>/test/image.png</code></p> <p>The second part is just your usual "if file does not exist, rewrite to /index.php"</p> <p><strong>EDIT</strong></p> <p>On a sidenote</p> <blockquote> <p>OP stated "this doesn't work" - well, thank you for trying - I was close to delete my answer after this helpful comment, but after the work I put into this post and since I verified the suggested solution to be working perfectly, I decided to take a breath and give some debugging tips.</p> </blockquote> <p>This said, if this does not work for you:</p> <ul> <li>Make sure your "hidden" upload folder is actually called <code>ftp-upload</code>, also, Linux is <strong>case sensitive</strong></li> <li><p>Make sure your webserver is configured to read .htaccess files:</p> <ul> <li><a href="http://httpd.apache.org/docs/2.2/en/mod/core.html#allowoverride" rel="nofollow">AllowOverride</a> directive in your vhost configuration.</li> <li>Usual value would be <code>AllowOverride All</code></li> <li>You can simply test this by adding something invalid (e.g. <code>givemeanerror on</code>) to your .htaccess and open the page in your webbrowser. If your .htaccess file is read, you will get a 500 Internal Server error message in your browser. If you don't have a test environment, you can do this in a test subfolder</li> </ul></li> <li><p>The configuration I posted above should replace the <strong>entire</strong> content of your <code>.htaccess</code> file which is placed in your <code>DOCUMENT_ROOT</code> (NOT inside the ftp-upload folder), for debugging even remove the <code>&lt;IfModule&gt;</code> wrapper, which can be put back in once this is working</p></li> <li><p>for testing, copy an image file into your ftp-upload folder, let's say <code>test.png</code></p></li> <li>if you still can't access <a href="http://yourdomain.com/test.png" rel="nofollow">http://yourdomain.com/test.png</a> in a browser, I'd like to see the response headers for this request</li> <li>if you don't know how to watch response headers go to <a href="http://www.webconfs.com/http-header-check.php" rel="nofollow">http://www.webconfs.com/http-header-check.php</a>, type in the URL <code>http://yourdomain.com/test.png</code> and copy the result</li> </ul> <p>Hope this helps :)</p>
    singulars
    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.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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