I'm moving my project to production, I was in a develop environment and everything worked correctly (localhost).
When I migrate to production the calls by AJAX do not find the route I need. (Error 404)
EDITO
The variable 'bu' already brings the base_url (), but curiously it is the IP of the server and not the url www.misitio.com (for example)
This is an example that is in JS:
function callAjax( u, m, d = {}, c, a = true ){
$.ajax({
url: bu + u,
method: m,
async: a,
data: d,
beforeSend: function(){
},
complete: function(){
},
success: c,
error: function( e ){
if( e.status >= 400 && e.status < 500){
renderMessage( 'Servicio no disponible', 'error' );
}
else if (e.status >= 500 && e.status < 600) {
renderMessage( 'Ocurrió un error en el servidor', 'error' );
}
}
});
}
callAjax('Items','GET',null,function( r ){});
This is the Items handler
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Items extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->model('items_model');
$this->load->helper('query');
$q = $this->items_model->getItems();
echo queryToJSON( $q );
}
}
?>
And finally this is my .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
I do not know if I have to add the route in the routes.php file or in config, I do not understand if it worked well in develop that is happening in production.
Thanks