2017-08-05 32 views
0

在我的Web應用程序上傳圖像時,圖像存儲在/public/uploads/目錄中。對於那些熟悉Slim Framework 3的人來說,/public/目錄是存儲index.php的地方。Slim Framework 3 RESTful後端 - 提供圖像

只是導航到http://website.com/uploads/image.png不起作用,因爲我認爲它尋找一個苗條3路線?

爲了讓我在導航到圖像時預覽圖像,是否必須在我的REST應用程序中製作自定義路線?

的.htaccess:

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule^index.php [QSA,L] 
+0

show you'r'.htaccess'-file。 – jmattheis

+0

@jmattheis添加了我的.htaccess – Jordan

回答

0

我只是單純地在我的上傳目錄做了一個新的.htaccess文件和它的工作。

我的文件聯繫人下面RewriteEngine Off

0

嘗試這樣的事情。 (我沒有檢查代碼)。

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]