html.htaccessroutesstatic-pages

Routing in static html landing page


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/


Solution

  • 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".