在静态 html 登陆页面中路由 [英] Routing in static html landing page
问题描述
我有一个基于 js/css/html 的小型投资组合登录页面.没有框架/CMS,只有纯静态 html.入口点是 index.html
文件,内容为英语.
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.
我想在我的网站上使用翻译:index.ru.html
、index.ua.html
,但我不想看到任何 *.html
或 index.ua
在地址栏中.用户可以通过我页面顶部的按钮更改语言.
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.
我如何路由:
http://mysite/en
显示index.html
- 首先进入网站http://mysite/ru
显示index.ru.html
http://mysite/ua
显示index.ua.html
http://mysite/en
to displayindex.html
- first enter to sitehttp://mysite/ru
to displayindex.ru.html
http://mysite/ua
to displayindex.ua.html
?
我也可以路由到特定的 div/section html 标签:用户输入 http://mysite/ru/contacts
以在 index.ru.html
中显示联系人部分?滚动页面也必须改变url...是真的还是假的?
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?
在这个网站上找到了很好的例子 - http://www.even.lv/
Found good example on this site - http://www.even.lv/
推荐答案
尝试将其添加到您的 Root/.htaccess 中:
Try adding this to your Root/.htaccess :
RewriteEngine On
RewriteBase /
RewriteRule ^en/?$ index.html [NC,L]
RewriteRule ^(ru|ua)$ index.$1.html [NC,L]
这会将/en"重定向到/index.html",将/ru"重定向到index.ru.html".
This will redirect "/en" to "/index.html" and "/ru" to "index.ru.html".
这篇关于在静态 html 登陆页面中路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!