Web.config并将子域映射到文件夹 [英] Web.config and mapping subdomains to folders

查看:143
本文介绍了Web.config并将子域映射到文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个子域名: dev.mydomain.com archive.mydomain.com ,以及 www.mydomain.com

I've got three subdomains: dev.mydomain.com, archive.mydomain.com, and www.mydomain.com.

是否可以创建一个 web.config 文件,该文件将请求映射到给定的子域到文件夹坐在与该子域匹配的webroot?

Would it be possible to create a web.config file that will map requests to a given subdomain to a folder sitting in the webroot that matches that subdomain?

例如。如果我的 D:\inetpub 文件夹包含 dev \ index.fm archive \\ \\ _index.cfm www \index.cfm ,我想将请求映射到 http:/ /dev.mydomain.com/index.cfm 到第一个, http://archive.mydomain.com/index.cfm 到第二个, http://www.mydomain.com/index.cfm 到第三个。

E.g. if my D:\inetpub folder contains dev\index.cfm, archive\index.cfm, and www\index.cfm, i'd like to map requests to http://dev.mydomain.com/index.cfm to the first, http://archive.mydomain.com/index.cfm to the second, and http://www.mydomain.com/index.cfm to the third.

感谢您的支持考虑!

推荐答案

我建议您查看URL重写。有一些很棒的付费免费那些。他们接受IIS级别的所有请求,将它们与正则表达式表进行比较,然后静默地重新映射您指定的URL。

I'd recommend that you look into URL Rewriting for this. There's some great paid and free ones out there. They take all requests at the IIS level, compare them to a regular expression table and silently re-map and URLs that you specify.

取决于您对表达式的处理方式将是这样的:

Depending on what you go with your expressions would be something like:

RewriteCond %{HTTP_HOST} ^(dev|archive|www).mydomain.com$
RewriteRule ^/(.*)$ /$0/$1 [F]

这篇关于Web.config并将子域映射到文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆