How to redirect from domain to telegrams?

Hello! Please tell me how to create a redirect domain on telegrams.
Now the access is closed t.me. How to do so. The man inserts his username or channel. Gets a reference to test.ru/логин and the redirect goes to telegrams. The similarity https://tg1.me/

Maybe there is documentation or an example.
March 19th 20 at 09:01
1 answer
March 19th 20 at 09:03
tg://resolve?domain=durov
It is clear! How to make people put your username or the same channel. And automatically issued to him. test.ru/его login. He copies and pastes in the search engine and automatically throws to the opening of the telegrams. There is an example https://tg1.me/ - Maudie_Moen commented on March 19th 20 at 09:06
@Maudie_Moendepends on the web server and PL - roma.Ada commented on March 19th 20 at 09:09
@roma.Ada, you Know that you can write in JS or PHP on the same this website.

I need to figure out how to implement it. Perhaps there is documentation or reference.
Or to prompt where to dig to realize what took off as an example. - Maudie_Moen commented on March 19th 20 at 09:12
@Maudie_Moen, you first need some way to read the login from the address bar, on apache+php this can be done by swapping parts of the string in a get parameter using RewriteRule. After getting login you need to make the link with the Protocol tg:// and redirect to it in any way - roma.Ada commented on March 19th 20 at 09:15
@roma.Ada, I am working through nginx. Here is a sample JS code.

I need to make it so that when pressing to address.
The bottom code worked and was redirected test.ru/логин on behalf of the telegrams.
the <script>var url=window.location.pathname.split("/");switch(url[1]){case"socks":var str="tg://socks"+window.location.search;break;case"share":str="tg://msg_"+url[2]+window.location.search;break;case"joinchat":str="tg://join?invite="+url[2];break;case"addstickers":str="tg://addstickers?set="+url[2];break;case"proxy":str="tg://"+url[1]+window.location.search;break;default:str="tg://resolve?domain="+url[1]+window.location.search.replace("?start=","&start=");url[2]&&(str=str+"&post="+url[2])}document.getElementById("abc").href=str;setTimeout(function(){window.location.replace(str);}, 5000);</script>
- Maudie_Moen commented on March 19th 20 at 09:18

Find more questions by tags Processing URL