0

I get things working with help by styfle, and now I have this working: olympiccode.xyz/download/plugin/hgjg/ff olympiccode.xyz/download/plugin/anything/here

Now I want to redirect by the input on the URL, for example, if a person used this URL: olympiccode.xyz/download/plugin/anything/here How I can redirect him to olympiccode.xyz/download/files/pl/anything-here.jar (the anything-here.jar is changed by what the person put in the URL)

//Old question

I don't know the name of this things so I used "Custom automatic URL", what I mean is some links like those:

https://crafatar.com/capes/jeb_
https://crafatar.com/capes/Notch
---
https://inventivetalent.org/download/plugin/Test/1.5
https://inventivetalent.org/download/plugin/CustomUrl/1.345344.345345

How it work? is it really done with javascript? how I can do it? [/spoiler]

TxCraft
  • 35
  • 10
  • That URL system where you can write whatever you want and always will generate a page with the info based on what you write – TxCraft Mar 25 '16 at 00:36

1 Answers1

1

I sounds like you want to handle URL Routing (sometimes called URL Mapping) with javascript.

It's unclear if you want to do server-side routing with node.js, or if you want to do client-side routing in the browser so I will link an isomorphic router which works in both environments called director.

Performing routing in the browser was typically restricted to window.location.hash for urls like http://example.com/#about and http://example.com/#downloads.

However, HTML5 provides a History API to rewrite the URL as http://example.com/about and http://example.com/downloads

Read more about the history.pushState() on MDN.

styfle
  • 22,361
  • 27
  • 86
  • 128
  • I now get it working on my website with: http://olympiccode.xyz/download/plugin/hgjg/ff/ http://olympiccode.xyz/download/plugin/anything/here/ But for example, if a person used this URL: http://olympiccode.xyz/download/plugin/anything/here/ How I can redirect him to http://olympiccode.xyz/download/files/pl/anything-here.jar (the anything-here.jar is changed by what the person put in the URL) – TxCraft Mar 25 '16 at 11:31
  • I think what you want is a [Redirect](http://stackoverflow.com/q/768431/266535) – styfle Mar 25 '16 at 12:47
  • But how I can get what the user put in the URL? – TxCraft Mar 25 '16 at 15:35
  • Try the [HTTP_REFERER](http://stackoverflow.com/q/165975/266535) header – styfle Mar 29 '16 at 14:58