bcosca / fatfree

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

psr4 with index in public folder

archistico opened this issue · comments

I code with fat-free-framework and I try use this structure

app/  
   Controller/  
   View/  
   ...  
vendor/  
public/  
   img/
       logo.png
   index.php  

composer.json

{
   "require": {
      "bcosca/fatfree": "^3.7"
   },
   "autoload": {
      "psr-4": { "App\\": "app/" }
   }
}

my .htaccess in folder public with index.php is:

RewriteEngine On
RewriteBase /
RewriteRule ^(app|tmp)\/|\.ini$ - [R=404]

RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /index.php [L,QSA]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

home.htm

<img src="{{ @BASE }}/images/logo.png"  alt="Logo"   class="brand-image">

when my route is "site.com/controller" logo is ok
when I have "site.com/contoller/action" logo not found

I have this error:
[404]: GET /controller/images/logo.png - No such file or directory

Why F3 find my public/image/logo.png in controller/ ?

In your layout.htm or container html page, do you have a tag for declaring your base url <base href="https://www.example.com/"> ? Either that or can you show what is actually rendered in your src attribute? It also might be helpful to see how your routes are laid out.

Perfect resolved