Welcome Guest, Not a member yet? Register   Sign In
Yet another htaccess question...
#1

[eluser]HovaCarlito[/eluser]
Hey guys,

I'm starting to use CodeIgniter (love it), but I've got a (probably stupid) question.

I managed to fix my .htaccess file so it doesn't require that nasty index.php.

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

Basically I work in a /dev directory, that's why I removed the first slash in the RewriteRule.

Everything works great (I can use relative links and such), but if I get into a page which uses functions or variables (like page/22) the relative links stop working, logically because they refer to page/css instead of /css.

Is there any way to 'force' it to understand that everytime I use a css/image/js link, I mean it needs to get back to the base dir without giving up my relative links? I'd love to recyle the view that holds the header of my page.

I'm sorry if my explanation of the problem of a bit ... vague or odd.

Thanks in advance.
#2

[eluser]troy_mccormick[/eluser]
[quote author="HovaCarlito" date="1268446426"]Basically I work in a /dev directory, that's why I removed the first slash in the RewriteRule.[/quote]

Because you are working in a subdirectory...try this:

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

I'm sure I'm missing something stupid there...but give it a shot :-)
#3

[eluser]HovaCarlito[/eluser]
Thanks for the (quick) reply!

Sadly, that didn't fix the problem.

Come to think of it... I doubt it's actually possible. The problem isn't really in the .htaccess (it does what it's supposed to do) but in where the browser will look for my css/image files. I guess making those links absolute it the only solution. Or am I wrong?
#4

[eluser]troy_mccormick[/eluser]
I never use absolute paths for my CSS. Sorry I completely mis-understood ya! :-)

What I do is something like this for a directory structure:

Code:
/application
/system
/resources

Then within the views I can just do a:

Code:
<link rel="stylesheet" href="/resources/css/style.css" type="text/css" media="screen" />

Maybe that will get you on the right track...

Good luck!
#5

[eluser]HovaCarlito[/eluser]
Yeah, that was basically was I was thinking about now too. And for the dev phase just add the /dev/css and not just css/.

Thanks a lot, even though my problem now has a totally different sollution Smile




Theme © iAndrew 2016 - Forum software by © MyBB