Remove index.php with mod_rewrite but keep css/site.css

[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?

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)

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.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.