URL in browser's URL bar changes quickly because of web forwarding

蓝咒 提交于 2019-12-11 06:44:50

问题


I have a VPS with the IP 123.123.123.123 and Apache listens there on port 7010. (I only have ports 7000 ... 7020 for myself).

I have registered a domain mydomain1.com by a domain provider and they offer a "web forwarding" :

Name                TTL     Type    Priority    Content        Forwards to
*.mydomain1.com     3600    A       0           212.20.xx xx   http://123.123.123.123:7010/

It works! Now when I write http://www.mydomain1.com in the browser URL bar, it automatically goes to http://123.123.123.123:7010/.

Problem: the browser URL bar only displays http://www.mydomain1.com for 0.5 seconds, and then displays http://123.123.123.123:7010/ instead, which is not nice in terms of user experience.

How to keep the display http://www.mydomain1.com in the browser URL bar?

Should I hack this with Javascript history.pushState(...)?

Should I do this in .htaccess with some ReverseProxySomething?

Another method?


回答1:


Going from "Default Forwarding" to "Framed" by the domain provider simply solved the problem.

The only drawback is that this is the resulting HTML, so this means it's some sort of hack...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<frameset frameborder="no" border="0" framespacing="0">
    <frame src="http://123.123.123.123:7010/" name="mainFrame" id="mainFrame" title="mainFrame" />
</frameset>
<noframes>
    <body>
        <a href="http://123.123.123.123:7010/">Click to be redirected</a>
    </body>
</noframes>
</html>

Still looking for a better / cleaner solution!



来源:https://stackoverflow.com/questions/40600286/url-in-browsers-url-bar-changes-quickly-because-of-web-forwarding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!