Welcome Guest, Not a member yet? Register   Sign In
mod_rewrite problems
#1

[eluser]Unknown[/eluser]
HI everyone! I`m new to this awesome framework, and i`m still learning, so i decided to get the base Url (index.php) removed from any string. This works perfectly.

Where i used to have:
http://localhost/index.php/login

i changed it to :
http://localhost/login

Works great ! However, i ended up with a huge problem. My CSS paths and JS files cannot be found anywhere. Where a normal relative path would be src/css/default.css, i get nothing.

So i was wondering how this could happen. I tried changing the relativa paths to ../src/css/ and so on, however, i cannot seem to get my css paths back.

Any one know what to do on this? (Ps. i used to mod_rewrite on the httpd.conf AND the .htacces). I had to to do this, since my Windows installation ( vista ) doesn`t like rewriting urls.

Anyway, any help is welcome!

Yours sincerely James
#2

[eluser]Jondolar[/eluser]
There are two ways to solve this (maybe more).

1. Hard-code the full path. Not very portable but it will work. Instead of using src/css/default.css use /src/css/default.css. Notice the first slash starts the path from the root of your domain.

2. Load the URL helper libarary and use the base_url() function in your view to display the base path to the application. This will only work if your css files are within the application directory structure.
#3

[eluser]Kepler[/eluser]
It also would help to post the changes you made to http.conf and .htaccess
#4

[eluser]Unknown[/eluser]
Thanks everybody!

@Kepler, the changes ( not many in fact ) are here;

in the httpd.conf i added these lines:

//??//??//??//

uncommented the rewrite_engine

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^(/index\.php|/img|/js|/css|/robots\.txt|/favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
//??//??//??//

( as found in the wiki on code igniter)

And i made a .htaccess file with the following conditions:

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

Which basicly arranges the actual rewriting. Whereas i already configured the mod_rewrite to be on in the httpd.conf. However, if one of these 2 files is not modified or i remove the htacces file, the rewriting fails, and i get a 404 error page.

I haven`t tried the absolute paths yet, so i`ll try that now! Anyway, thanks already for the help!

Yours sincerely,
James
#5

[eluser]Kepler[/eluser]
I would try changing the .htaccess file to:

Code:
RewriteEngine on
// Either add ALL non-codeigniter directories here:
RewriteCond $1 !^(index\.php|images|javascript|css|robots\.txt)
// OR use the following 2 lines:
// RewriteCond %{REQUEST_FILENAME} !-f
// RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]




Theme © iAndrew 2016 - Forum software by © MyBB