CodeIgniter Forums
Url rewrite uri problem - 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: Url rewrite uri problem (/showthread.php?tid=35918)



Url rewrite uri problem - El Forum - 11-15-2010

[eluser]mathg[/eluser]
Hi,

I have a small problem with my url rewrite to remove index.php. When I use an url like www.mysite.com/fr and I var_dump $RTR->uri I get this :

Code:
["keyval"]=> array(0) { }
["uri_string"]=> string(0) ""
["segments"]=> array(0) { }
["rsegments"]=> array(2) { [1]=> string(4) "main" [2]=> string(5) "index" }
...
["index_page"]=> string(0) ""
["uri_protocol"]=> string(4) "AUTO"
...

The uri object doesn't find any segment event though theres one.

When I use an url like www.mysite.com/index.php/fr

Code:
["keyval"]=> array(0) { }
["uri_string"]=> string(3) "/fr"
["segments"]=> array(1) { [1]=> string(2) "fr" }
["rsegments"]=> array(2) { [1]=> string(4) "main" [2]=> string(5) "index" }
...
["index_page"]=> string(0) ""
["uri_protocol"]=> string(4) "AUTO"
...

This time it finds an uri.

Why isn't it able to find an uri when there is not index.php in the url?

I'm using rewrite engine as follow in my .htacess.

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

Thanks for the help!


Url rewrite uri problem - El Forum - 11-15-2010

[eluser]dudeami0[/eluser]
Code:
RewriteRule ^(.*)$ /index.php?/$1 [L]

That might do the trick.


Url rewrite uri problem - El Forum - 11-15-2010

[eluser]mathg[/eluser]
It did the trick! Thank you very much!

I thought I copied the rule from mod_rewrite wiki, but it looks like no since I forgot that question mark after the index.php... So much time lost for so little...

Thx again!


Url rewrite uri problem - El Forum - 11-15-2010

[eluser]dudeami0[/eluser]
Yeah, when your looking at code all day things like that can fly way over your head :p