Welcome Guest, Not a member yet? Register   Sign In
Rewrite .htaccess rules fail. Any help?
#1

[eluser]Rubiz'[/eluser]
Hello guys!

Im trying to rewrite the URL, removing the index.php as I have seen in user guide, but it doesnt work.

Im using:
Code:
RewriteEngine on
RewriteRule ^(.*)$ /index.php/$1 [L]

My CI folder is inside http://site.com/folder

When I upload the .htaccess file, the app seams to point to http://site.com/, I dont know why its happening...

Any idea?

Thanx!
#2

[eluser]Narkboy[/eluser]
Rewrite is always relevent to the folder you place the .htaccess file in.

If you're placing the .htaccess in '/' then it will go looking for '/index.php'. If you want:

http://site/

to load

http://site/folder/index.php

then the .htaccess needs to be:

Code:
RewriteEngine on
RewriteRule ^(.*)$ /folder/index.php/$1 [L]

Or similar. Also remember than as it stands, this rule redirect *everything* to index.php - so any requests for css, js or img files will go to index.php. You'll need to specify certain folders / files for mod_rewrite to ignore if you want that type of request served properly.

I use:

Code:
RewriteEngine on

RewriteBase /

RewriteCond $1 !^(index\.php|image|style|license\.txt|robots\.txt|sitemap\.xml|script|user_guide)
RewriteRule ^(.*)$ /index.php?$1 [L]

This means any request for '/image/*', '/style/* etc. are properly directed.

The 'RewriteBase' can be user if you're placing the .htaccess in asubfolder below root. You don't need to for CI unless you're running multiple installs on a single server.

Smile




Theme © iAndrew 2016 - Forum software by © MyBB