开发者

Can I use domain masking plus get the URI passed?

开发者 https://www.devze.com 2023-04-06 09:13 出处:网络
I have a dyndns.org account which goes to my home computer. That all works fine, wordpress is installed.

I have a dyndns.org account which goes to my home computer. That all works fine, wordpress is installed.

I want to buy a domain (mysite.com) and have it mask to mysite.dyndns.org while passing back all of the additional URI goodness.

For example, if I go to mysite.com/page2 it should go to mysite.dyndns.org/pa开发者_Go百科ge2

Any thoughts on ways to accomplish this?


The answer turned out to be to use a CNAME record. CNAMES essentially act like symlinks.


Yes, assuming you want to keep hash parameters in addition to query parameters, you could accomplish such a thing with a little piece of JavaScript like the following:

if (window.location.host == 'mysite.com') {
   var current_url = window.location.href;
   var new_url = current_url.replace('mysite.com', 'mysite.dyndns.org');
   window.location.href = new_url;
}

If you don't need to preserve hash parameters, then you could implement similar redirect logic in the web server or in the server-side scripting language of your choice, by checking the HTTP "Host" header for the current host name, and issuing a 301 redirect as needed.

However, I really do not understand why you would want your system to be set up in this way. Typically custom domains are more trustworthy than domains hanging off of "dyndns.org". Why not just have your custom domain configured to point to the correct IP address(es)? Most web hosting solutions will automatically provide the appropriate DNS configuration.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号