0

When uploading images on my web application, images are stored in the /public/uploads/ directory. For those familiar with Slim Framework 3 the /public/ directory is where index.php is stored.

Simply navigating to http://website.com/uploads/image.png does not work for I presume it looks for a Slim 3 route?

In order for me to preview images in when navigating to the image, do I have to make a custom route in my REST application?

.htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
Jordan
  • 231
  • 1
  • 12

2 Answers2

0

I just simply made a new .htaccess file in my uploads directory and it worked.

My file contacts the following RewriteEngine Off

Jordan
  • 231
  • 1
  • 12
0

Try something like this. (I didn't check code).

RewriteEngine On

//Is file not exist then rewrite to index.php 
RewriteCond %{DOCUMENT_ROOT}/public%{REQUEST_URI} !-f
RewriteRule ^ index.php [QSA,L]

// file exist then rewrite to new path and try again with new path.
RewriteCond %{DOCUMENT_ROOT}/public%{REQUEST_URI} -f
RewriteRule ^(.*)?$ /public/$1 [QSA,L]
John Tribe
  • 1,407
  • 14
  • 26