Asi
Asi

Reputation: 415

HTACCESS Rewrite 3 Parameters

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?

Upvotes: 1

Views: 606

Answers (1)

Abhishek Gurjar
Abhishek Gurjar

Reputation: 7476

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

Upvotes: 1

Related Questions