如何通过要求用户将他们的名字放在网址中来显示随机页面?

时间:2017-07-30 11:34:28

标签: html routing url-routing

我遇到过facebook页面上说的这个东西

  

在网址中注明您的姓名以显示此类&这样的事情   自己

例如 https://www.downloadanysong.com/william https://www.downloadanysong.com/john 这显然告诉你应该听什么歌。

他们是如何做到的?

2 个答案:

答案 0 :(得分:0)

it depends on what technology their using in JavaScript you can the url with window.location.href and then they could just split it after the last / to find the name you typed in. And index an object full of songs to find which one goes with that name. Otherwise, if their doing it on the server side, it's completely dependent on the language their using.

答案 1 :(得分:0)

this can be done using MVC or Model View Controller, Where the URL is analyzed please note that this is not possible using htacess rewrite conditions.

a good reference to start is the below How does an MVC system work?