Open internal site - mod_rewrite

I host a website ( http://gfd.us) locally that I would like to open on the Internet. I have a second-level public domain name (of NoIP): http://myname.ddns.netthat points Default Web Siteto my IIS server.

The problem is that a second level domain name is also expected on the internal website, i.e. http://secondname.gfd.us.

Right now, to solve this problem, I am using the mod_rewriteIIS module form , binding to a specific port, i.e.

mod_rewrite rule parameters

  • Template - (.*)
  • Condition - {SERVER_PORT} = 91
  • Rewrite the URL: http://secondname.gfd.us/{R:1}

Everything works as expected, when I open http://myname.ddns.net:91, it will actually open the internal websitehttp://secondname.gfd.us

I don't like that if I need to use another second level domain name for an open website, i.e. http://coolname.gfd.us, then I need another rule to bind to a different port. I would like it to be more dynamic.

I tried to change the template so that it was (.*)\gfd_(.*), and the rewrite URL is http://{R:2}.gfd.us/{R:1}, but it does not work properly. When I open http://myname.ddns.net:91/gfd_coolname, the site itself opens with the necessary second-level domain name, but all CSS, JS, and image files point to invalid URLs because they are not rewritten correctly.

Is it possible to achieve use mod_rewrite?

+4
source share
1 answer

, mod_rewrite - Host-Headers,

gfd.us IP- myname.ddns.net

, IIS10, .

0

Source: https://habr.com/ru/post/1618849/


All Articles