Welcome Guest, Not a member yet? Register   Sign In
htaccess causes loss of stylesheet
#1

[eluser]Michael;[/eluser]
For some reason when I try to use the CI Guide version of an .htaccess to remove 'index.php' from my urls I lose all reference to my style sheet in my views:

from my template:
<link href="<?=base_url()?>files/css/default.css" rel="stylesheet" type="text/css" />

I do not have 'index.php' in the base url config, as I missing something here?

Thanks!
#2

[eluser]Disaster[/eluser]
You gotta add your "files" dir to your .htaccess, like so:

RewriteCond $1 !^(index\.php|files|robots\.txt)
#3

[eluser]Elliot Haughin[/eluser]
Try using this one instead...

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

It basically says, if the file doesn't exist, then hit index.php/
#4

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

The above htaccess allow access only to "index.php", "robots.txt" and the folders "css", "images", "files" and "scripts". It is more secure this way, because nobody will have direct access to the "system" folder. You can add how many directories you want in the list, but do not add directories where you have PHP files.
#5

[eluser]Michael;[/eluser]
Hmmm... Now, I'm getting a 500 Internal Service Error when using any of the above suggestions except Elliot's, which I land on the index page with no url segments, but then get the 500 Internal Service Error when I try to get to any other pages.

This is my first attempt at using htaccess for rewriting urls, so I appreciate your guys' help!

Thanks!
#6

[eluser]Edemilson Lima[/eluser]
My example above works fine with my provider. Maybe your host needs something different. Below are some links with tutorials about the htaccess, may you find them interesting.

http://www.freewebmasterhelp.com/tutorials/htaccess/

http://www.javascriptkit.com/howto/htaccess.shtml

http://www.sitedeveloper.ws/tutorials/htaccess.htm

http://codeigniter.com/wiki/Dreamhost_.htaccess/
#7

[eluser]treadsoftley[/eluser]
I have mod_rewrite working just fine but now I need a type of 'splash' page - something I'd normally avoid but in this occasion it's right for the job. The client also requires that this page is www.example.com and not something I could easily set up via a redirect eg www.example.com/home/

If I remove my .htaccess rewrite I can make this happen easily by placing an index.html (which is looked for first) alongside my index.php. But as soon as I add my normal .htaccess file, the base url finds my codeigniter inital page not my splash page

I have tried this, in hope that www.example.com would again find index.html in preference over index.php but it still finds my codeigniter page.
Code:
RewriteEngine On

RewriteCond $1 !^(index\.php|http://www\.example\.com|index.html|images|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

I hope what I'm looking for is clear enough. Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB