Welcome Guest, Not a member yet? Register   Sign In
CSS external files.
#11

[eluser]Silviu[/eluser]
That's some sort of light blue... try adding some other rules too and also try inspecting your document with Firebug (or similar) to see what rules are applied where...
#12

[eluser]mlakhara[/eluser]
No rules are applied to the page..
#13

[eluser]InsiteFX[/eluser]
If you used my folder structure then use this.
Code:
RewriteEngine on  
    RewriteCond $1 !^(index\.php|assets|images|css|js|robots\.txt|favicon\.ico)  
    RewriteCond %{REQUEST_FILENAME} !-f  
    RewriteCond %{REQUEST_FILENAME} !-d  
    RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

If that does not work then you have something else wrong some place else!
#14

[eluser]mlakhara[/eluser]
No InsiteFX.
The htaccess file was same.
still i applied what you gave and its still not working.
I dont know why its not working because i can access the css file by using the url:
Code:
http://localhost/codlib/codlib/assets/css/style.css
That does means that the css files are already exceptions to the routing rules.
I also checked for image file inclusion. The following code did what it was supposed to do. It included the appropriate image. No styles again.
Code:
<html>
<head>
<title>The MNITLIB APP</title>
    <link type="text/css" href="<?php echo base_url('assets/css/style.css');?>" media="screen"/>
</head>
<body>
<h1>Malviya National Institute Of Technology</h1
<div id="login_form">
&lt;?php echo form_open('login/validate_credentials');?&gt;
Email id: &lt;?php echo form_input('username');?&gt;
Password:&lt;?php echo form_input('password');?&gt;
&lt;?php echo form_submit('submit','LOGIN');?&gt;
&lt;?php echo form_close();?&gt;
<img src="&lt;?php echo base_url('assets/images/pic1.jpg')?&gt;" />
</div>
&lt;/body&gt;
&lt;/html&gt;
#15

[eluser]mlakhara[/eluser]
Well the problem is solved. But the peculiar thing is I dont know why?
I replace code segment 1 with code segmnet two and voila! it worked.
Code:
&lt;link type="text/css" href="&lt;?php echo base_url('assets/css/style.css');?&gt;" media="screen"/&gt;
Code:
&lt;link rel="stylesheet" type="text/css" href="&lt;?php echo base_url('assets/css/style.css');?&gt;" media="screen"/&gt;

was there any CI specific error with the previos line?
#16

[eluser]InsiteFX[/eluser]
Yes. because you were missing this which tells html what type of file it's loading.
Code:
type="text/css"

The HTML base Element
The &lt;base&gt; tag specifies a default address or a default target for all links on a page:
Code:
&lt;base href="&lt;?php echo base_url();?&gt;" /&gt;

Link to an external style sheet:
Code:
&lt;link rel="stylesheet" type="text/css" href="theme.css" /&gt;
#17

[eluser]EyeAmN8[/eluser]
I am also new to CI and have been having trouble with the whole re-write part of it. Everything got messed up after I used the tutorials .htaccess snippet.

I found some better info on the web and combined it with the above mentioned code and now my css files are being rendered properly. Thanks for all of the posts!
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    #RewriteCond %{REQUEST_URI} ^application.*
    #
    # edited the below line to accept the needed contents of the assets folder
    RewriteCond $1 !^(index\.php|assets|images|css|js|robots\.txt|favicon\.ico)
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>
#18

[eluser]CroNiX[/eluser]
You could replace all of that, with just this:
Code:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

The system and application directories are already protected in CI 2+, so you are duplicating it and it's unnecessary. (see the included htaccess in /system and /application which deny direct access)

You don't need to explicitly exclude directories/files like:
Code:
RewriteCond $1 !^(index\.php|assets|images|css|js|robots\.txt|favicon\.ico)
when you have the lines
Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

Again, you're duplicating your efforts. The last 2 lines (-f/-d) covers anything you could possible put in that exclude statement. You should use one or the other, but not both. The second method is much better than the first as it covers all real files/directories outside of /system and /application, so if you add some other image dir or something later you don't have to update your htaccess with it.
#19

[eluser]EyeAmN8[/eluser]
hey thanks for the tip! I tried it and it works.




Theme © iAndrew 2016 - Forum software by © MyBB