Create a file named .htaccess
in the root folder and add this:
RewriteEngine On
RewriteRule ^([a-z0-9_]+)$ painel/view/$1.php [L]
If the files are case-sensitive, you can do the following:
RewriteEngine On
RewriteRule ^([a-z0-9_]+)$ painel/view/$1.php [NC,L]
-
The ([a-z0-9_]+)
looks for only named files that have letters, numbers, and underline
-
The ^
and $
do check from start to finish to match
-
The $1
takes what you have inside the parantes and adds to get the "true" request
-
The NC
causes regex to be case-insensitive (in the first case it does not)
-
The L
ignores the next rules ( RewriteRule
) avoiding conflicts
If error 500 occurs, there are two possibilities:
- You added something else inside your .htaccess, which is conflicting
- Or you did not enable mod_rewrite in apache (which is kind of rare these days)