Problems with css, js and addressing when passing to the server with codeigniter

0

Some time ago I am working on a project that I developed in Codeigniter 3.x where I carry out the typical actions of CRUD, in addition to the call to JOBS in SQL Server.

When testing the service locally, it does not present any inconvenience, everything works super well, loads all .css and .js, correctly generates the address, and everything is great.

To do the addressing, I have done it using the helper ('url') which allows me to use base_url

Every call, whether CSS, js, or other pages, I have made with that helper.

So far so good ... The problem arises when I transfer my project to the server. When executed locally (on the server), it works without problems. But I need other users to connect to it and conduct their operations.

at the moment of entering from another computer to the address of that server the page loads, but without .css, nor .js, nor redirects ...

I put an example of how I'm calling each .css in the view:

  <head>
    <title>Finanzas</title>
      <link rel="stylesheet" href="<?php echo base_url('assets/css/bootstrap.css'); ?>" />
      <link rel="stylesheet" href="<?php echo base_url('assets/DataTables/DataTables-1.10.16/css/dataTables.bootstrap.min.css');?>"/>
      <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">  <!-- este funciona bien, pues no es con base_url -->
      <link rel="shortcut icon" href="<?php echo base_url('imagenes/favicon.ico');?>" />
  </head>

My base_url:

$config['base_url'] = 'servidor:4002/codeigniter/';

Naturally this code is only able to load the element that is being called without the base_url.

When viewing through the "view source code" of the browser, I click on the called element, and it does not open the .css immediately, I must copy the link, paste it in the browser and press enter.

Any ideas?

Thanks in advance for the time and help!

    
asked by estimaops 17.11.2017 в 13:56
source

2 answers

3

The server is on the same network, therefore I can access it via the address:

server / project

Anyway, I just found the solution to my problem:

I found this solution in this forum. I had researched a lot but just when I posted the question, I found the answer ...

link THANK YOU Risa__B (I could not tag you)

the one in response to another user posted:

  

what happens is that localhost only exists on your computer, that's why it's   localhost, from other computers and phones you can not use   localhost because said url does not exist uses the following better, that's what   I also use and it works perfect:

    $config['base_url'] = 'http://'.$_SERVER["SERVER_NAME"].'/Alumbrado/'
    $_SERVER["SERVER_NAME"]
  

this works to capture the name of the server (domain) in which   you are currently

WITH IT WORKS PERFECTLY!

    
answered by 17.11.2017 в 14:29
0

To access your website what url do you use? In theory you must have a domain with which you enter type " link ". Well it is this url that you must put in base_url:

$config['base_url'] = "http://www.midominio.es";
    
answered by 17.11.2017 в 14:12