[英]IIS server url rewrite
For example, I have a domain example.com
and my server IP is 1.1.1.1
that is running Microsoft IIS server on Windows Server 2016 Datacenter
DNS 记录是A *.example.com 1.1.1.1
我想做服务器, 1.1.1.1
显示C:\inetpub\*
下的内容
如果目录不存在,服务器应该返回 404 错误。
例如:
|--C:\
|-- inetpub\
|-- a
|-- b
|-- c
将结果:
a.example.com
显示C:\inetpub\a
下的内容b.example.com
显示C:\inetpub\b
下的内容c.example.com
显示C:\inetpub\c
下的内容d.example.com
返回HTTP/1.1 404 Not Found
谢谢。
请将 map 这些文件夹作为您网站下的虚拟目录。
例如:/a->c:\inetpub\a。 /b->c:\inetpub\b.
然后你就可以轻松地将 a.example.com/test.aspx 重写为 a.example.com/a/test.aspx。 如果文件夹不存在。 然后 d.example.com/d/ 只会返回 404。
<rule name="rewrite">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="(.*)\.example\.com" />
</conditions>
<action type="Rewrite" url="{C:1}/{R:1}" />
</rule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.