我正在尝试通过Azure CDN Verizon Premium使用Azure Storage Static Website托管一个Angular项目
假设我为每个名为v0.3.13.3的Angular构建都有容器,并且在这个容器中还有angular项目的多语言构建。
我正在努力实现的是为每个版本和语言提供正确的index.html和正确的路由。
您可以在下面找到示例路由:
my.domain.com/v0.3.13.3应该为/v0.3.13.3/index.html服务
my.domain.com/v0.3.13.3/dashboard应该为/v0.3.13.3/index.html服务
my.domain.com/v0.3.13.3/fr应该为/v0.3.13.3/fr/index.html服务
my.domain.com/v0.3.13.3/fr/dashboard应该为/v0.3.13.3/fr/index.html服务
我已经设法用Azure Standard Rules Engine做到了这一点,如下面的屏幕截图所示。

但就我在文档中看到的,在标准规则引擎中,Contains字段不能用正则表达式填充。我翻遍了谷歌,但似乎找不到任何适合我的解决方案。
因此,我将我的CDN服务切换到了Verizon Premium,并尝试将(v(?:(\d+)\.)?(?:(\d+)\.)?(?:(\d+)\.\d+))应用于path regex。
我在使用Verizon Premium时遇到的主要问题是,如果我将if字段声明为Always,则只能应用URL Rewrite功能

如您所见,URL Rewrite并未列出。
此外,我已经使用Always语句进行了几次部署,但效果并不好。
每个人都在他们的博客中分享的一个例子

因此,上面的示例不包括文件扩展名和子路由。
有什么方法可以实现我的目标吗?
提前谢谢。
发布于 2020-12-16 01:07:47
我会在规则V4中分享我在Verizon Premium中使用的当前配置:步骤如下:
添加新规则: General Always
/80XXXXXX/XXXXXX/((?:[^\?]*/)?)($|\?.*)
/80XXXXXX/XXXXXX/index.html$2
/80XXXXXX/XXXXXX/((?:[^\?]*\/)?[^\?\/.]+)($|\?.*)
/80XXXXXX/XXXXXX/index.html$2此外,您还可以获取此处https://stackoverflow.com/a/58700538/3591687中描述的来源
这是生成的XML规则
<policy>
<rules>
<rule>
<match.always>
<feature.url.url-rewrite source="/80XXXXXX/XXXXXX/((?:[^\?]*/)?)($|\?.*)" destination="/80XXXXXX/XXXXXX/index.html$2"/>
<feature.url.url-rewrite source="/80XXXXXX/XXXXXX/((?:[^\?]*\/)?[^\?\/.]+)($|\?.*)" destination="/80XXXXXX/XXXXXX/index.html$2"/>
</match.always>
</rule>
</rules>
</policy>我希望这对某些人有帮助
发布于 2020-11-25 00:13:03
请在下面的规则引擎4.0中查看如何在Azure CDN中选择URL重写-文档目前缺乏,仍在尝试使其工作。一旦这篇文章设置正确,我就会更新它

发布于 2022-03-02 23:40:43
我最终通过复制重定向来解决源服务器的两个哈希,在我的例子中从00和08开始,最终让重定向工作。
然后,您尝试使用08散列进行部署,系统会报告您没有更改任何内容。:)
所以我只是复制代码,在晚上对着枕头哭。
根据记录,当您将draft更改为策略时,如果您尝试使用包含类似/0-9+的正则表达式在"feature.url.url-redirect source“部分中进行部署,系统将报告来源与任何已知来源不匹配。
这就是对我有效的方法。如果有人有更好的解决方案,我欢迎!
<policy>
<rules>
<rule>
<description>Redirect HTTP to HTTPS 00 Version</description>
<match.request.request-scheme.literal value="http">
<feature.url.url-redirect source="/00XXXXXX/www-example-com/(.*)" destination="https://%{host}/$1" code="302"/>
</match.request.request-scheme.literal>
</rule>
<rule>
<description>Redirect HTTP to HTTPS 80 Version</description>
<match.request.request-scheme.literal value="http">
<feature.url.url-redirect source="/80XXXXXX/www-example-com/(.*)" destination="https://%{host}/$1" code="302"/>
</match.request.request-scheme.literal>
</rule>
<rule>
<description>Site redirects to 00 Version</description>
<match.request.request-scheme.literal value="https">
<select.first-match>
<match.url.url-path.regex result="match" value="[\/#]*\/dir1\/subdir1.*" ignore-case="true" encoded="false">
<feature.url.url-redirect source="/00XXXXXX/www-example-com/.*" destination="https://www.example.com/#/dir1/subdir1" code="302"/>
</match.url.url-path.regex>
<match.url.url-path.regex result="match" value="[\/#]*\/folder2\/subfolder2.*" ignore-case="true" encoded="false">
<feature.url.url-redirect source="/00XXXXXX/www-example-com/.*" destination="https://www.example.com/#/folder2/subfolder2" code="302"/>
</match.url.url-path.regex>
<match.url.url-path.regex result="match" value=".*" ignore-case="true" encoded="false">
<feature.url.url-redirect source="/00XXXXXX/www-example-com/.*" destination="https://www.example.com/" code="302"/>
</match.url.url-path.regex>
</select.first-match>
</match.request.request-scheme.literal>
</rule>
<rule>
<description>Site redirects to 80 Version</description>
<match.request.request-scheme.literal value="https">
<select.first-match>
<match.url.url-path.regex result="match" value="[\/#]*\/dir1\/subdir1.*" ignore-case="true" encoded="false">
<feature.url.url-redirect source="/80XXXXXX/www-example-com/.*" destination="https://www.example.com/#/dir1/subdir1" code="302"/>
</match.url.url-path.regex>
<match.url.url-path.regex result="match" value="[\/#]*\/folder2\/subfolder2.*" ignore-case="true" encoded="false">
<feature.url.url-redirect source="/80XXXXXX/www-example-com/.*" destination="https://www.example.com/#/folder2/subfolder2" code="302"/>
</match.url.url-path.regex>
<match.url.url-path.regex result="match" value=".*" ignore-case="true" encoded="false">
<feature.url.url-redirect source="/80XXXXXX/www-example-com/.*" destination="https://www.example.com/" code="302"/>
</match.url.url-path.regex>
</select.first-match>
</match.request.request-scheme.literal>
</rule>
</rules>https://stackoverflow.com/questions/62647432
复制相似问题