在静态 html 登陆页面中路由 [英] Routing in static html landing page

查看:86
本文介绍了在静态 html 登陆页面中路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于 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.htmlindex.ua.html,但我不想看到任何 *.htmlindex.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.

我如何路由:

  1. http://mysite/en 显示index.html - 首先进入网站
  2. http://mysite/ru 显示index.ru.html
  3. http://mysite/ua 显示index.ua.html
  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

?

我也可以路由到特定的 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆