Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/04/2011, 21:52
Avatar de Danielfuzz
Danielfuzz
 
Fecha de Ingreso: septiembre-2007
Mensajes: 111
Antigüedad: 16 años, 7 meses
Puntos: 18
Pregunta CodeIgniter: Problema con enlaces css, js

Holas!!

estoy empezando con los frameworks en php y empiezo con el pié izquierdo ya que al parecer mis archivos img, css, js, swf, etc. no se están enlazando correctamente cuando mi url tiene mas de un nivel, es decir si miURL es:

http://localhost/cic/noticias => carga bien
http://localhost/cic/ => carga bien

pero ya no se cargan si tiene mas niveles como:

http://localhost/cic/noticias/noticia/7/titulo-7

la única forma que encontre de solucionar es usando el helper site_url("css/style.css") , pero no se si existe una mejor forma de solucionar esto, ya que tendria que poner este helper en todos los enlaces a archivos css, js, swf, img de mis vistas.

mis carpetas de imagenes, js, css, etc están ubicadas en la raíz de la aplicación (osea al mismo nivel que "index.php" y las carpetas "application", "system", etc)

Les dejo alguna info que podria ayudar a solucionar el problema:

mi vista cabecera que uso en todas las paginas:
Código HTML:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jquery.dropshadow.js" type="text/javascript"></script>
<script type="text/javascript">
	$(document).ready(init);
	function init(){
		$('#divMenu').dropShadow({top:0,left:0,blur:8,opacity:0.75});
	}
</script>
</head> 
mi .htaccess con el que quité el index.php de la URL

Código:
<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 ^(.*)$ /cic/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.*
    RewriteRule ^(.*)$ /cic/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 ^(.*)$ cic/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 /cic/index.php
</IfModule>

Saludos!!