1
I have a little MVC made by me. With urls of this type index.php?route=admin/produto/adicionar
, but I wanted to withdraw index.php?route=
, I already got some lines .htaccess
stay that way www.exemplo.com/admin/produto/adicionar
, the problem is that after css and js files are not found (www.exemplo.com/public/public/js/404.php
):
.htaccess:
RewriteEngine On
RewriteBase /wtj/public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?route=$1 [L]
File structure:
configs/paths.php (this is where I define the paths):
// folder name => path
return [
"configs" => "../app/configs",
"controllers" => "../app/controllers",
"css" => "../public/css",
"images" => "../public/images",
"js" => "../public/js",
"includes" => "../public/views/includes",
"lang" => "../app/lang",
"views" => "../public/views"
];
Real message on console, files to search:
Which is the redirect programmed to my 404 page.
The right page (route) is assumed and goes to the right controller/method, but external files are troublesome.
Hello, thanks but I also have something like this in my project. A file that returns an array with the paths. I edited above
– Miguel
I tested it now and it actually works with absolute paths :). Thank you
– Miguel