1

I want to have a website with few languages with default English.

domain.com will show English homepage (this will load the index.php without any parameters)

domain.com/fr/ will show French homepage (this will load the index.php with the parameter lang=fr)

domain.com/fr/articles/ will show the articles.php page with the parameter lang=fr

domain.com/fr/articles/article1.html will show the articles.php page with 2 parameters, First lang=fr and Second slug=article1

domain.com/fr/games/ will show the games.php page with the parameter lang=fr

domain.com/fr/games/best-game.html will show the games.php page with 2 parameters, First lang=fr and Second slug=best-game

Can someone PLEASE help me do this complected .HTACCESS file?

Asi
  • 395
  • 4
  • 13
  • 3
    Possible duplicate of [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](http://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) – Croises Aug 26 '16 at 18:49
  • It doesn't give answers for 3 parameters, I wouldn't waste your time guys if the answer was there – Asi Aug 29 '16 at 18:56

1 Answers1

1

Although your question seems bit broad but please try this I've checked it, if any error occurs please mention

DirectoryIndex index.php

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([a-zA-Z_-]+)$ index.php?lang=$1 [NC]
RewriteRule ^([a-zA-Z_-]+)/$ index.php?lang=$1 [NC]
RewriteRule ^([a-zA-Z_-]+)/([a-zA-Z]+)/$ $2.php?lang=$1 [NC]
RewriteRule ^([a-zA-Z_-]+)/([a-zA-Z]+)/(.*).html$ $2.php?Firstlang=$1&Secondslug=$3
Abhishek Gurjar
  • 7,426
  • 10
  • 37
  • 45
  • Thank you but this is just one language , I want the /fr to be change for all the links so some will have domain.com/no/articles/Articles .html and some domain.com/es/games/ – Asi Aug 27 '16 at 14:56
  • You did just one parameter. I hope the code can work with 3 parameters: Language, filename (articles, games, news, or others), the 3rd parameter will be . Html and will represent slug parameter – Asi Aug 27 '16 at 15:00
  • try the edit now you can use any language and if you want everything dynamic please mention. – Abhishek Gurjar Aug 27 '16 at 17:07
  • You are pro Abhishek! Missing the dynamic page, games, articles, hotels, news and so on – Asi Aug 28 '16 at 05:21
  • domain.com/fr Error 404 – Asi Aug 28 '16 at 10:39
  • domain.com/fr gives 404 but domain.com/fr/ looks ok. Is there a way to support both ? – Asi Aug 28 '16 at 12:23