Escape "/" with htaccess and / or php

1

I have a small MVC made by me. With urls Of this type index.php?route=admin/produto/adicionar , but I wanted to remove index.php?route= , I already got a line of .htaccess that was thus www.exemplo.com/admin/produto/adicionar , the problem is that later the 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(hereiswhereIdefinethepaths):

//foldername=>pathreturn["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 fetched:

  

GET link

     

GET link

What is the redirect scheduled for my 404 page.

The right (route) page is assumed and goes to the right controller / method, but the external files are giving problems.

    
asked by anonymous 02.11.2015 / 18:38

1 answer

0

The problem of not finding the paths is related to the relativity of the paths. Instead of defining the paths in /app/configs/paths.php as array , set the paths in the root to /index.php through DEFINE so you can use the constant throughout the scope of the project through absolute path. >

index.php (In some line before running your MVC)

DEFINE('PATH_CONFIGS', 'app/configs/');
DEFINE('PATH_CONTROLLERS', 'app/controllers/');
DEFINE('PATH_LANG', 'app/lang/');
DEFINE('PATH_CSS', 'public/css/');
DEFINE('PATH_IMG', 'public/images/');
DEFINE('PATH_JS', 'public/js/');
DEFINE('PATH_VIEWS', 'public/views/');
DEFINE('PATH_INCLUDES', PATH_VIEWS.'includes/');

When calling the constant, just call it like this:

echo PATH_CSS;

And if you want to continue the path path, simply concatenate from the absolute path you already have:

echo PATH_CSS . "cssAdmin/seu_arquivo.css";
    
02.11.2015 / 20:01