Welcome Guest, Not a member yet? Register   Sign In
Can't link to css file if remove index.php using .htaccess file
#1

[eluser]ammtar[/eluser]
I have test site and it use css file
Code:
<link rel='stylesheet' type='text/css' media='screen' href='<?=base_url()?>/includes/css/style.css' />
and works fine.

But when I create .htaccess file to remove index.php in URL, the css is broken. Even if I use
Code:
<link rel='stylesheet' type='text/css' media='screen' href='http://mysite.co/includes/css/style.css' />
css file would not be recognized/found.

?!?!?!?
#2

[eluser]ammtar[/eluser]
SOLVED

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|includes|css)
RewriteRule ^(.*)$ /index.php/$1 [L]

I had to add "includes" and "css" (directories)
#3

[eluser]fesweb[/eluser]
You are going to have a lot more problems if you don't change it to something more like this:
Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
This version only rewrites urls that do NOT point to actual files or directories. With your version requests for images, pdfs, css, js, etc will all get sent through CodeIgniter, which is not what you want.

EDIT: IN other words, you would have to alter your htaccess every time you want to add a directory to your server.




Theme © iAndrew 2016 - Forum software by © MyBB