Htaccess Page Translation

Htaccess Page Translation

Use Google Translate to enable auto translation for foreign speakers to use your site. NOT CLOSE TO PERFECT but a nice feature with htaccess.

Step 1: Add language code to end of URL’s – for example this URL would be https://www.astralwebinc.com/htaccess_page_translation.php-he

Step 2: Add to htaccess file

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)-he$ http://www.google.com/translate_c?hl=he&sl=en&u=http://example.com/$1 [R,NC]
RewriteRule ^(.*)-fr$ http://www.google.com/translate_c?hl=fr&sl=en&u=http://example.com/$1 [R,NC]
RewriteRule ^(.*)-de$ http://www.google.com/translate_c?hl=de&sl=en&u=http://example.com/$1 [R,NC]
RewriteRule ^(.*)-es$ http://www.google.com/translate_c?hl=es&sl=en&u=http://example.com/$1 [R,NC]