IIS web.config - 多个网站的相同文件 [英] IIS web.config - same file for multiple websites

查看:96
本文介绍了IIS web.config - 多个网站的相同文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个IIS 7.5(不使用ASP)以及以下网站:




  • 网站A

  • 网站B

  • 网站C

  • 网站D

  • 网站E



网站B 站点C 站点D 属于使用相同 web.config 。虽然IIS允许我们为每个站点的所有使用web.confg加上继承的web.config,但似乎没有选择将站点分组以限制此全局继承。 / p>

为了说明问题,我将在其内容后调用web.config:




  • 网站A /www/static/site_A/web.config中使用web.config company-website

  • 网站B 使用web.config central-cms /www/cms/site_B/web.config

  • 网站C 使用web.config central-cms /www/cms/site_C/web.config

  • 网站D /www/cms/site_D/web.config中使用web.config central-cms

  • 网站E 在<$中使用web.config community-board c $ c> /www/boards/site_E/web.config



如您所见,我们虽然有5个物理web.config文件其中3个(B,C,D)包含相同的内容。



我们希望站点B,C和D共享一个web.config文件,但仍然需要站点A和E使用他们自己的web.config 而不必否定继承



可能的结构:




  • /www/static/site_A/web.config (无继承)

  • /www/cms/web.config (基础继承)

    • / www / cms / site_B / web.config (+继承)

    • /www/cms/site_C/web.config (+继承)

    • /www/cms/site_D/web.config (+继承)


  • /www/boards/site_E/web.config (无继承)



注意:所有web.config文件都为< system.webServer>声明了各种重写规则和指令。



IIS 7.5是否具备此功能?


解决方案

w eb.config应该能够实际执行此操作。将常见的web.config文件放入每个站点具有读取权限的文件夹中。然后修改单个web.config文件以调用公共文件:

 < appSettings file =/ path / to / some /common/web.config\"> 

然后这个公共文件可用于任何需要它的文件,而忽略那些不需要它的文件。您甚至可以将其重命名为common.config或其他东西,以便它不会被继承。所以这可行:

 < appSettings file =/ www / common.config> 

所有子目录都应具有读取权限,因为它不是web.config它应该'搞乱任何派生的应用程序设置。



注意:以这种方式包含配置文件时,对包含文件的更改不会触发应用程序回收与直接更改web.config的方式相同。这不应该是一个问题,因为您只需要重新启动应用程序池,但最初可能会让人感到困惑。


We have an IIS 7.5 (not using ASP) with the following sites:

  • Site A
  • Site B
  • Site C
  • Site D
  • Site E

Site B, Site C and Site D belong to a centralized application that uses the same web.config. While the IIS allows us to use a web.confg for all of them plus an inherited web.config for each site, there does not seem to be an option to group sites to restrict this global inheritance.

To illustrate the problem, I will call the web.config after their content:

  • Site A uses web.config "company-website" in /www/static/site_A/web.config
  • Site B uses web.config "central-cms" in /www/cms/site_B/web.config
  • Site C uses web.config "central-cms" in /www/cms/site_C/web.config
  • Site D uses web.config "central-cms" in /www/cms/site_D/web.config
  • Site E uses web.config "community-board" in /www/boards/site_E/web.config

As you can see, we have 5 physical web.config files although 3 of them (B, C, D) contain the same content.

We want Site B, C and D to share a single web.config file, but still want Site A and E to use their own web.config without having to negate inheritance.

Possible structure:

  • /www/static/site_A/web.config (no inheritance)
  • /www/cms/web.config (base inheritance)
    • /www/cms/site_B/web.config (+ inheritance)
    • /www/cms/site_C/web.config (+ inheritance)
    • /www/cms/site_D/web.config (+ inheritance)
  • /www/boards/site_E/web.config (no inheritance)

Note: All web.config files declare various rewrite rules and directives for <system.webServer>.

Is IIS 7.5 capable of this?

解决方案

The web.config should be capable of doing this actually. Put the common web.config file into a folder that each site has read permission for. Then modify the individual web.config files to call the common file:

<appSettings file="/path/to/some/common/web.config">

Then this common file can be used for any files that need it and ignored for those that don't. You can even rename it to common.config or something so that it doesn't get inherited. So this would work:

<appSettings file="/www/common.config">

All children directories should have read access to it, and since it's not a web.config it shouldn't mess with any application settings that are derived.

Note: When including a config file in this manner, changes to the included file do NOT trigger an application recycle in the same manner that a direct change to the web.config would. This should not truly be a problem since you simply have to restart the application pool, but it can be confusing at first.

这篇关于IIS web.config - 多个网站的相同文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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