0
Good morning! I’m making a small website, using Codeigniter 3 and Bootstrap 3.
On the PC, CSS and JS work perfectly well, but when I try to access it from Smartphone, by localhost, load only the HTML.
Observing: I’m using the XAMPP.
What can it be?
*Example of CSS Call:
<link href="<?php echo base_url('assets/css/site.css'); ?>" rel="stylesheet">
*Example of JS call:
<script src="<?php echo base_url('assets/js/site.js'); ?>"></script>
*Base URL is configured this way:
$config['base_url'] = 'http://localhost/teste';
*On the PC, type the URL: localhost/test. - Works normally.
*On the smartphone I type the IP address instead of "localhost": EX.: 192.168.x. x/test. - Does not load CSS or JS. Only HTML.
Please increment your question with codes, CSS calls, so we can help you better
– William Aparecido Brandino
Question edited. I added code.
– Eduardo Maia
Dude, your base_url constant has to automatically pick up the url, not manually set
– flourigh
has a completion code down there, but you can use this also define('BASE_URL', $_SERVER['HTTP_HOST']); echo BASE_URL
– flourigh
Thanks for your help, but unfortunately it didn’t work out. Based on your answers, I found a satisfactory answer on the Internet, which solved my problem. Link: http://www.universidadecodeigniter.com.br/optimizando-a-configuracao-da-url-base-da-aplicacao/
– Eduardo Maia
$base_url = "http://" . $_SERVER['HTTP_HOST']; $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), "", $_SERVER['SCRIPT_NAME']); $config['base_url'] = $base_url;
– Eduardo Maia