Created
June 28, 2020 23:29
-
-
Save hugodias/83b83d0092e6586dc041f8256f41f691 to your computer and use it in GitHub Desktop.
Multi Language WordPress htaccess
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BEGIN WordPress | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase / | |
RewriteRule ^(br|en|es)$ index.php?lang=$0 [L,QSA] | |
RewriteRule ^index\.php$ - [L] | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule . /index.php [L] | |
</IfModule> | |
# END WordPress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function is_multilanguage_front_page() | |
{ | |
return ! empty($_GET) && ! empty($_GET['lang']) && in_array($_GET['lang'], array( | |
"en", | |
"es", | |
"br" | |
)); | |
} | |
function language_redirect($template) | |
{ | |
if (is_multilanguage_front_page()) { | |
return locate_template(array('front.php')); | |
} else { | |
return $template; | |
} | |
} | |
add_action('template_include', 'language_redirect'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment