bcosca / fatfree

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!
2.66k stars 446 forks source link

psr4 with index in public folder #1210

Closed archistico closed 3 years ago

archistico commented 3 years ago

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/ ?

n0nag0n commented 3 years ago

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.

archistico commented 3 years ago

Perfect resolved