5

I have a small portfolio landing page based on js/css/html. No frameworks/CMS, just pure static html. Entry point is index.html file with content on English language.

I want to use translations on my site: index.ru.html, index.ua.html, but I don't want to see any *.html or index.ua in the address bar. User can change a language by buttons on top of my page.

How can I route:

  1. http://mysite/en to display index.html - first enter to site
  2. http://mysite/ru to display index.ru.html
  3. http://mysite/ua to display index.ua.html

?

Also can I route to specific div/section html tag: user enter http://mysite/ru/contacts to display contacts section in index.ru.html? Scrolling page also must change url... is it real or not?

Maybe I need to use micro-framework for my small needs?

EDIT:

Found good example on this site - http://www.even.lv/

Sogl
  • 782
  • 3
  • 9
  • 29
  • Have you tried making each a separate subdomain? That seems to be what a lot of websites use. – Rob Rose Jul 31 '15 at 05:26
  • @RobertRose, You mean `en.mysite.com` etc? I don't think it's good for SEO and domain name becomes ugly. Even Microsoft with their [locale list](https://www.microsoft.com/en-us/locale.aspx) doesn't do this. – Sogl Jul 31 '15 at 06:33

3 Answers3

4

Try adding this to your Root/.htaccess :

RewriteEngine On
RewriteBase /
RewriteRule ^en/?$ index.html [NC,L] 
RewriteRule ^(ru|ua)$ index.$1.html [NC,L]

This will redirect "/en" to "/index.html" and "/ru" to "index.ru.html".

Amit Verma
  • 40,709
  • 21
  • 93
  • 115
  • It works with ru/ua correctly, but not redirect from `mysite.com` to `mysite.com/en` – Sogl Aug 06 '15 at 08:09
0

Might be using bootstrap scroll spy you can take user to sepecific section. if you don't want url to be change in that case ajax will help you. with use of jQuery you can trigger select change function jQuery("#language-select").change(function(){ // your logic try ajax here to change portion on page. })

0

Make directories for each language and put the relevant pages inside.

The only mechanism you have that allows you to omit a full url is the ability of the web server to serve a "default" page, which in your case is an index.html

By the same token to support mysite/ru/contacts you would need a directory structure of:

mysite/
      ru/
        contacts/
             index.html

In other words, with pure html pages and without using rewrites, you can accomplish your structure with directories off the webroot and creating many individual index.html pages.

The other option is to use rewrite rules like those available using mod_rewrite and the apache web server.

Those rules require a good working understanding of regular expressions.

gview
  • 14,876
  • 3
  • 46
  • 51
  • This idea came to my head when I'm asked this question =) But what about entry point? I need redirect or something from root to `/en` catalogue with `index.html` on English. – Sogl Jul 31 '15 at 05:50
  • Your root index.html can be assumed to be English. You still need an /en directory tree for all the other pages, but not for the default/home page. – gview Jul 31 '15 at 08:07