Rewriting rules for language virtual folder |
[eluser]kakawett[/eluser]
Hi, All my urls are like this : localhost/controller/function, except for the pages I need an ID. I have 2 questions. 1. If I am using an ID like this : http://localhost/blog/post/1, I get the id with $this->uri->segment(3);, is there a better way to do it ? something a little bit cleaner ? 2. I would like to insert the language code in the url like this : /lg/controller/function (/id) for example : http://localhost/ch_DE/about/informations and to get my variable ch_DE... but I don't know what to change in routes configuration file ... or htaccess ? and I don't know how to get the variable in my PHP script using $this->uri ? I have this htaccess : RewriteEngine on RewriteCond $1 !^(index\.php|misc|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] Thanks in advance.
[eluser]n0xie[/eluser]
1. I prefer this : Code: controller Blog extends Controller { 2. Take a look here : i18n support or URI_Language_Identifier
[eluser]kakawett[/eluser]
1) What ?? I'm just asking for something else than $this->uri->segment(3) to get the ID 2) Thanks, I guess it's what I need - gotta try.
[eluser]n0xie[/eluser]
[quote author="kakawett" date="1254336067"]1) What ?? I'm just asking for something else than $this->uri->segment(3) to get the ID [/quote] And that's exactly what my example does. It will fill in the ID in the variable $post_id, unless you don't supply one; then it will default to NULL which is easy to track using is_null.
[eluser]kakawett[/eluser]
Yeah but where is $post_id defined ? I don't, does CodeIgniter alone ? I just tried, it says "$post_id undefined" or something like that.
[eluser]n0xie[/eluser]
Code: controller Blog extends Controller { |
Welcome Guest, Not a member yet? Register Sign In |