[英]base_url() link CODEIGNITER
我的base_url
有問題
我不明白為什么我放<? php echo base_url ()?> asset / css / style.css
<? php echo base_url ()?> asset / css / style.css
我無法到達目的地。
如果我在瀏覽器中輸入相同的鏈接到css文件,則該鏈接實際上是正確的。 在實踐中,據我了解到的結果是:localhost / site / localhost / assets / css / style.css
我怎樣才能得到:
localhost / site /assets / css / style.css
使用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');
在config.php
文件中
$config['base_url'] = 'http://localhost/website/';
$config['index_page'] = '';
# If you have online website
# $config['base_url'] = 'http://stackoverflow.com/';
在.htaccess
(外部應用程序文件夾)中-從URL中刪除index.php
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]
訪問URL
<a href="<?php echo base_url();?>contoller_Name/method_Name"> click here</a>
訪問圖像
<img src="<?php echo base_url();?>images/images.jpeg”>
訪問js和CSS
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/css/style.css">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.