Welcome Guest, Not a member yet? Register   Sign In
base_url() and css -img-js
#1

[eluser]Ngulo[/eluser]
hi all,i've read we must always use base_url() before all img tags or css's links or js's links is it true?

i would like to use this method but...

i'm having serious problem loading css and js sheets

i've put my css and js folders on the same level of index.php and system folder

i'm using links like this:

Code:
<link rel="stylesheet" href="../css/template.css" type="text/css" media="screen">

and all works in application folder ,

but for example:

if i load www.asd.it the css and js's takes away

instead
if i load www.asd.it/index/Home they are showed

i haven't take away with .htaccess the index.php i'm working on the basics ,without changing $config's data(changed only the main features like base_url() and default controller .... Sad
#2

[eluser]Krzemo[/eluser]
I don't quite get what you mean, but using base_url() will solve all your problems for sure Smile
#3

[eluser]Ngulo[/eluser]
yes ,i'm exscusing form my bad english Sad, i was trying to found a different way for loading css or js's sheets ,without using base_url(); on all tags Sad Sad

so, there's no way to call all css sheets and js's using simple href like css/style.css or ../css/style.css Sad i need to put base_url(); anyway Sad ??
#4

[eluser]Clifford James[/eluser]
What is your folder structure?

I'm using links like this:
Code:
<link href="<?=site_url('assets/stylesheets')?>/style.css" rel="stylesheet" type="text/css" media="screen" />
#5

[eluser]Ngulo[/eluser]
i'm using this configuration:
http://www.greggoforth.net/article/5
#6

[eluser]Clifford James[/eluser]
In that case you can use the code I mentioned above.
#7

[eluser]Ngulo[/eluser]
yep Sad i know Sad eheheh i'm crying Sad

Smile i will always use this method also for all img tags ...crying Sad

Smile
#8

[eluser]Sergiu D[/eluser]
Hello there,

My name is Sergiu, and I'm not new to CodeIgniter, but I'm new to all this rewrite crap. So, my problem is pretty similar to my fellow above me. Now, I think I've read almost all topics on this forum regarding .htaccess modifications, and right now I'm pissed off. :-)

I am trying to figure out a solution to this. My problem is that, I don't want to put extra code in my projects. I don't want to use something like this:

Code:
<link href="<?=site_url('assets/stylesheets')?>/style.css" rel="stylesheet" type="text/css" media="screen" />

I want to use something nice and cleaner, like:

Code:
<link href="css/style.css" rel="stylesheet" type="text/css" media="screen">
<img src="images/foobar.jpg" alt="">


Now, back in the old days, when we didn't had to worry about SEO and stupid friendly links, we could have accomplish that task with no sweat. But now, well... now is another story. The biggest problem is that I have some links to images, like the one above, in my database, that I just can't change (and don't want, to be truly honest).

Is there no way, and I mean, NO WAY, to make things work?
Let's say I have this directory structure:

Code:
/
/css
/js
/imags
/system
.htaccess
index.php

I am using this in my .htaccess:

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|template|scripts|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

What condition can I add in .htaccess to make this work in my page?

Code:
&lt;link href="css/style.css" rel="stylesheet" type="text/css" media="screen"&gt;
<img src="images/foobar.jpg" alt="">
#9

[eluser]InsiteFX[/eluser]
Code:
&lt;head&gt;
&lt;base href="http://www.yoursite.com/" /&gt;
&lt;/head&gt;

&lt;body&gt;
<img src="images/stickit.gif" />
&lt;/body&gt;

InsiteFX
#10

[eluser]aminem9[/eluser]
Hello I tested this is it works very well

/
/css/style.css
/js
/imags
/system
.htaccess
index.php

&lt;link href="../css/style.css" rel="stylesheet" type="text/css" media="screen"&gt;

was very soon Smile




Theme © iAndrew 2016 - Forum software by © MyBB