4
I have the following URL:
http://192.168.1.67/plays/mvc/index.php?route=profile&user=mikas.28
On which route = PAGE and user = USERNAME.USERID
I have the following htaccess
Options -Multiviews
RewriteEngine On
RewriteBase /plays/mvc
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?route=$1 [L]
And what I got was:
http://192.168.1.67/plays/mvc/profile&user=mikas.28
Worked to eliminate index.php?route=, I tried to add other Rules that fit to eliminate the others but could not.
My goal is to achieve http://192.168.1.67/plays/mvc/profile/mikas.28
If this is achieved I have to change something in my index.php?
$router = new Router();
if(isset($_GET['route'])) {
   $route = $_GET['route'];
}
else {
   $route = 'home';
}
if(!is_null($router->get($route))) {
   $r = $router->get($route);
   $controllerName = $r['controller'];
   $methodName = $r['method'];
   require_once "controllers/" .$controllerName. '.php';
   $controller = new $controllerName();
   $controller->$methodName();
}
else {
   echo "404 Not Found!";
}
I’ve had this kind of problem but I couldn’t solve, hopefully someone will answer us!! Excellent question.
– Renoir Reis
Thank you, I always go around with htaccess
– Miguel
@Kaduamaral managed to adapt this response to my case. Thank you
– Miguel