is it possible to change address bar url?

polaris · · 739 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Let&#39;s say I have a domain name <a href="http://notalkingplz.com" rel="nofollow">http://notalkingplz.com</a> and it is permanently forwarded to my web server url <a href="http://myddns.com:8080" rel="nofollow">http://myddns.com:8080</a>. Is it possible to have the url address bar say <a href="http://notalkingplz.com" rel="nofollow">http://notalkingplz.com</a> instead of <a href="http://myddns.com:8080" rel="nofollow">http://myddns.com:8080</a>? Cloaked/stealth forwarding isn&#39;t exactly an option because I need to be able to use meta viewport, so I&#39;m wondering if I could do it on the server itself.</p> <p>edit: my web server is currently a very basic web server that consists of a few lines of code and uses httprouter</p> <p>TL;DR: can you change the url in the address bar of a browser using go</p> <hr/>**评论:**<br/><br/>dfndoe: <pre><p>This doesn&#39;t seem to be even remotely a go question...</p></pre>notalkingplz: <pre><p>My question is basically, can you change the url in the address bar of a browser using go.</p></pre>kiasaki: <pre><p>What you want to search for is somewhat related to DNS</p> <p>You want to go to your hosting provider admin panel and add a CNAME from <code>notalkingplz.com</code> to <code>mydns.com</code> that&#39;s way it&#39;ll be effectively &#34;cloaking&#34; not redirecting.</p> <p>As for the port 8080, you have no choice but to listen on port 80 in you Go app to remove the need of having it in the url. (there are other ways, google reverse proxy but I am pretty sure this is too involving for your use case.</p> <p>Please research how HTTP works, understand the protocols and technologies than make the web works you will come out a way better programmer and will be able to ask the right questions in the right forums/communities for them, when in doubt post to StackOverflow.</p> <p>This is obviously not a go related question...</p></pre>notalkingplz: <pre><p>Let&#39;s say DNS is out of the picture. Is it possible to change the url in the address bar of a browser, using go?</p></pre>TwilightTwinkie: <pre><p>Not from your server end, and it&#39;s barely possible (as in I would have no idea how to do it at all) from the client end. Only Javascript can change the url from the browser and that forces a redirect. So the short answer is no. What you are doing is impossible with go, unless you write a DNA server in go which is a crazy round about approach to &#34;using go&#34;. </p></pre>notalkingplz: <pre><p>Thanks for the answer.</p></pre>bankslain: <pre><blockquote> <p>Only Javascript can change the url from the browser and that forces a redirect.</p> </blockquote> <p>Actually there&#39;s history.pushState. But it won&#39;t allow you to modify the scheme, domain, or port for obvious reasons.</p></pre>rainworm: <pre><p>Here are common methods: <a href="https://www.google.com/search?q=url+masking" rel="nofollow">https://www.google.com/search?q=url+masking</a></p> <p>It&#39;s a Go question like any other HTTP programming question. If you want to do better than those masking techniques, you&#39;d do it server side. Not unlike a reverse proxy, your Go servers would funnel requests/responses back and forth however you see fit. That assumes you&#39;d have a server under your control at the display domain too. If that&#39;s the case, you&#39;d surely have access to the name&#39;s DNS.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

739 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传