CodeIgniter Forums

Full Version: Remove index.php with mod_rewrite but keep css/site.css
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Brennan Novak[/eluser]

New to CodeIgniter, I'm loving it but just trying to work out some kinks.

I got the index.php removed but editing this line in config.php

Quote:$config['index_page'] = "index.php"; ===> $config['index_page'] = "";

And by adding this .htaccess file. I'm running MAMP on my Mac.

Quote:Options +FollowSymLinks
RewriteEngine On

RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

BUT I can't seem to keep my site.css file working. It tries to load the file via:


But gives me a CodeIgniter 404 page. Is there any place to add an "exception" to CI somewhere?

El Forum

Oh yes, surprisingly simple for you - its all about your htaccess. This line is what matters:

Quote:RewriteCond $1 !^(index\.php|images|robots\.txt)

What it is saying is "ignore index.php, robots.txt, and anything in the images folder.

Just add your 'ignore this' directories there and it should magically work!

As an example, this is my htaccess for my latest project:

Quote:RewriteCond $1 !^(index\.php|images|uploader|css|js|robots\.txt|favicon\.ico)

El Forum

I have found it's easier to put all your public files (most people call them assets) in a folder public.

So instead of adding all those folders separately, just move them to 1 folder public and just do this:

RewriteCond $1 !^(public|robots\.txt|favicon\.ico)

Now everything in your public folder won't be affected by your rewrite rules.