![]() |
Mod_rewrite, /controller/function, and CSS/JS - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Mod_rewrite, /controller/function, and CSS/JS (/showthread.php?tid=14654) |
Mod_rewrite, /controller/function, and CSS/JS - El Forum - 01-10-2009 [eluser]underskor[/eluser] Would someone care to explain how to use mod_rewrite, with /controller/function/argument URI's while allowing CSS/JS/images to continue functioning? Using the .htaccess sample provided on the forums/wiki seems to get me as far as /controller - awesome - but once I go into /controller/function, I lose my stylesheets etc. I imagine they are being rewritten to /controller/function/css/style.css, but I can't figure out how to stop that. My current .htaccess: Code: RewriteEngine On I think my problem is that I do not understand the last RewriteCond fully. I think it's something like 'apply the following RewriteRule if the pattern in RewriteRule is not 'index.php' or 'css'. I've tried changing 'index.php|css' around but had no luck. Would be great if someone could explain it for me. Directory structure (FWIW): Code: /public_html Thanks! underskor Mod_rewrite, /controller/function, and CSS/JS - El Forum - 01-10-2009 [eluser]jtkendall[/eluser] Hi underskor, Can you post your html lines for the CSS files? My guess would be that you need to use base_url() in front of the file location, for example: Code: <link rel="stylesheet" type="text/css" href="<?=base_url();?>style.css" /> or you can use a / and have it look at the web root for it. For example, I always put my css files in /assets/css/ so when I call one I use: Code: <link rel="stylesheet" type="text/css" href="/assets/css/style.css" /> Haven't had any problems with it (so far). Mod_rewrite, /controller/function, and CSS/JS - El Forum - 01-10-2009 [eluser]underskor[/eluser] Yeah I am using ./css/style.css to reference the CSS files as I have multiple local projects I am working on. Code: /project1 It would make sense to use /css/style.css - it would work on a production server - but on my development machine I would have to change the paths. Base_url() it is then! I will give it a go and post back. EDIT: Works great. Thanks Jtkendall. |