如何在IIS/web.config中重写仍然显示类型化/漂亮的URL?
问题描述:
我有一个htaccess
规则是这样的:如何在IIS/web.config中重写仍然显示类型化/漂亮的URL?
RewriteRule ^page/pretty/([A-Za-z0-9\-]+)-(.[A-Za-z0-9]*)/?$ /page/pretty/prettytemplatepage/?code=$2&path=page/pretty/$1-$2&slug=$1-$2 [P,L]
这个工作,让像一个网址:
site.com/page/pretty/some-pretty-page-ABCD
要在显示页面:
site.com/page/pretty/prettypagetemplate/?code=ABCD&path=page/pretty/some-pretty-page-ABCD&slug=some-pretty-page-ABCD
没有重定向/改变地址栏中的网址。我如何在Azure/IIS/web.config中完成同样的事情?
答
您要求的是反向代理实现。这可以使用ARR & URL重写模块。请参阅本文讨论如何实现此配置: Reverse Proxy with URL Rewrite v2 and Application Request Routing