php - Words in different languages in the url -


i have website in 3 languages. have 1 page code , change text each language.

just simplified example of same page in english , french:

mydomain.com/tap.php/?lang=en
mydomain/tap.php/?lang=fr

to clean url use:

rewriterule (mydomain)\/(\w{2})\/(.*) $1\/$3.php?lang=$2 

this redirects pages from:

mydomain/en/tap
mydomain/fr/tap

this works question is: is possible have words in different languages in url? instance, if user writes in french:

mydomain/fr/robinet

note: "robinet" "tap" in french

could redirected to:

mydomain/tap.php/?lang=fr

(remember have 1 page both languages, mydomain/fr/robinet.php/lang=fr not exist. make redirect last mydomain/fr/tap.php/?lang=fr doesn't seem efficient solution) maybe solution not in .htaccess?

so question is: how use words in different languages in url?

well seems pretty simple, in order not affect performance, make sure put rewrites in order going called least, use last rewrite flag on rules.

rewriterule (mydomain)\/(\w{2})\/(.*) $1\/$3.php?lang=$2 [l] rewriterule mydomain/fr/robinet mydomain/tap.php?lang=fr [l] 

if want automate though, you'll need on application logic, kind of routing. example in laravel have controller file, tapcontroller, , define routes kind of map points each word each controller.

route::get('/{lang}/{word}', function($lang, $word){     $map = [         'tap' => 'tapcontroller@'.$lang.'index',         'robinet' => 'tapcontroller@frindex'     ];      return app::make($map[$word]); }); 

the above may not valid code, haven't used laravel in quite while, illustrate idea.

eventually use rewrite map.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -