CodeIgniter Forums
Rewrite .htaccess rules fail. Any help? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Rewrite .htaccess rules fail. Any help? (/showthread.php?tid=36073)



Rewrite .htaccess rules fail. Any help? - El Forum - 11-20-2010

[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!


Rewrite .htaccess rules fail. Any help? - El Forum - 11-20-2010

[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