Welcome Guest, Not a member yet? Register   Sign In
base_url() in css and js
#2

[eluser]Clooner[/eluser]
[quote author="Felipe Deitos" date="1344861908"]Hi, i am having a hard time trying to discover what is the best way to build my css and js in the head of my document.

Its a local server, my base url in config.php is:
Code:
$config['base_url'] = 'http://localhost/orca/';

My htacess:
Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /orca/index.php/$1 [L]

My css/js/images are in a root folder called assets.

In my .php file i tryed to put the css 3 ways.
Code:
// 1 - Work in all pages but i dont really want to show the entire url in the source code http://localhost/orca/assets/css/styles.css
<link rel="stylesheet" type="text/css" media="screen" charset="utf-8" href="<?php base_url(); ?>assets/css/styles.css" />


// 2 - This work in pages that i only call the controller ex: http://localhost/orca/home/, if i call http://localhost/orca/home/thing/ the css stop work
<link rel="stylesheet" type="text/css" media="screen" charset="utf-8" href="assets/css/styles.css" />


// 3 - This doest not work at all
<link rel="stylesheet" type="text/css" media="screen" charset="utf-8" href="/assets/css/styles.css" />

I really dont want to use the entire url.. someone know what i am doing wrong?
[/quote]

If option 1 works all the time why not go with that? Why would you not want to show the entire url in the source of the html? It's as you pointed out the most stable solution. also it's
Code:
<?php echo base_url(); ?>


Messages In This Thread
base_url() in css and js - by El Forum - 08-13-2012, 05:45 AM
base_url() in css and js - by El Forum - 08-13-2012, 07:58 AM
base_url() in css and js - by El Forum - 08-13-2012, 08:09 AM
base_url() in css and js - by El Forum - 08-13-2012, 10:17 AM
base_url() in css and js - by El Forum - 08-13-2012, 05:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB