首页 > 解决方案 > URL Rewrite all folders at root of subdomain to folder in a different file path

问题描述

I need to rewrite from sub.domain.com/Xfolder/yfile.htm --> /local_path/all_customers/xfolder/yfile.htm

There are many xfolders in the all_customers folder. No folders or files exist in the IIS root of sub.domain.com. All of the folders and files actually exist in a local folder and not a URL.

I need something like this code, but I also need to allow for URL variables.

RewriteEngine on    
RewriteCond %{HTTP_HOST} !^sub\.domain\.com$ [NC]
RewriteRule !^file_path_to_folders\all_customers\$ [R=302,L]

标签: iismod-rewriteurl-rewritingweb-configurl-rewrite-module

解决方案


URL 重写模块只能将一个 URL 重写为另一个 URL,因此无法直接将 URL 重写为物理路径文件夹。您可以使用根文件夹创建另一个网站/local_path/all_customers/。这样您就可以轻松地反向代理siteA/Xfolder/yfile.htmsiteB/Xfolder/yfile.htm.

请安装 ARR 和反向代理来实现这一点。 ARR 和反向代理

并且反向代理功能默认禁用,因此您必须首先在“应用程序请求路由”功能中启用它。


推荐阅读