简体   繁体   中英

base_url() link CODEIGNITER

I have a problem with base_url

I do not understand why when I put <? php echo base_url ()?> asset / css / style.css <? php echo base_url ()?> asset / css / style.css

I can not reach my destination.

The link is correct in fact if I write the same in the browser I get to the css file. in practice from what I understand the result I get is: localhost / site / localhost / asset / css / style.css

how can i get:

localhost / site /assets / css / style.css

using base_url ();

index.php

 <head> <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/css/style.css"> </head> 

autoload.php

$autoload['helper'] = array('form', 'url', 'html');

In config.php file

$config['base_url'] = 'http://localhost/website/';
$config['index_page'] = '';

# If you have online website
# $config['base_url'] = 'http://stackoverflow.com/';

In .htaccess (outside application folder) - To remove index.php from URL

RewriteEngine on
RewriteCond $1 !^(index\.php|assets|image|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

To access URL

<a href="<?php echo base_url();?>contoller_Name/method_Name"> click here</a>

To access images

<img src="<?php echo base_url();?>images/images.jpeg”>

To access js and css

<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/css/style.css">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM