php - Why is making a Get request functioning in Xampp but not working when I deploy to Server?

My application tries to resemble an MVC architectural pattern. In Xampp the application works as it should. On the server it is deployed on, it does not work. I have narrowed down the problem, and it seems to happen every time I make a GET request from a form or if I click on a link that redirects me to another part of the site.
In Xampp the URL http://localhost/dealer_login/Quote/quoteDetails?quote_number=532468 On the hosted server the URL is http://webdev.fakesite.com/dealer_login-prod/public/index.php?url=Quote/reviewQuotesOrders
I have to add the public/index.php part. My .htaccess files don't seem to be working on the server.
Initially I didn't think it was a big deal, but when it comes to making "GET" request the URL is interpreted differently.
For example in Xampp http://localhost/dealer_login/Quote/quoteDetails?quote_number=532468 works fine.
It checks for a Quote class and then calls the quoteDetails method. Everything after the question mark is not considered part of the method in the Quote class.
Array ( [0] => Quote [1] => quoteDetails )
On the server quoteDetails?quote_number=532442 is being considered as part of a method in a class. It does not find it so I then get redirected to my index page.
Array ( [0] => Quote [1] quoteDetails?quote_number=532442 )
Why is this happening ?
Here is my core class which basically instantiates each class and calls its method based on whatever is in the URL.
<?php
/*
* App Core Class
* Creates URL & loads core controller
* URL FORMAT - /controller/method/params
*/
class Core
{
protected $currentController = 'Pages';
protected $currentMethod = 'index';
protected $params = [];
public function __construct()
{
$url = $this->getUrl();
// Look in controllers for first value
if (file_exists('../app/controllers/' . ucwords($url[0]) . '.php')) {
// If exists, set as controller
$this->currentController = ucwords($url[0]);
// Unset 0 Index
unset($url[0]);
}
// Require the controller
require_once '../app/controllers/' . $this->currentController . '.php';
// // Instantiate controller class
$this->currentController = new $this->currentController;
if (isset($url[1])) {
if (method_exists($this->currentController, $url[1])) {
$this->currentMethod = $url[1];
unset($url[1]);
}
}
print_r($url);
//If there is anything left in our Url after unsettting the current method and current controller then mass those values
//via the call_user_func_array.
//$this->params = $url ? array_values($url) : [];
call_user_func_array([$this->currentController, $this->currentMethod], $this->params);
}
public function getUrl()
{
if (isset($_GET['url'])) {
$url = rtrim($_GET['url'], '/');
$url = filter_var($url, FILTER_SANITIZE_URL);
$url = explode('/', $url);
return $url;
} else {
$url[0] = 'Pages';
return $url;
}
}
}
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: videoxxx
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.