用于存储静态网站子目录的Azure CDN Premium Verizon规则引擎V4 URL重写 [英] Azure CDN Premium Verizon Rules Engine V4 URL Rewrite for Storage Static Website sub directories

查看:68
本文介绍了用于存储静态网站子目录的Azure CDN Premium Verizon规则引擎V4 URL重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 Azure CDN Verizon Premium

比方说,我为每个 Angular 版本(如 v0.3.13.3 )命名都有容器,并且在该容器中还存在多语言版本的angular项目.

Let's say i have containers for each Angular builds named like v0.3.13.3 and in that container there are also multi language builds of angular project.

我要实现的目标是为正确的 index.html 提供正确的路由,以适用于每种版本和语言.

What i'm trying to achieve is to serve the right index.html with correct routing for each version and language.

您可能会在下面找到示例路线:

You may find example routes below:

my.domain.com/v0.3.13.3 应该投放/v0.3.13.3/index.html
my.domain.com/v0.3.13.3/仪表板应该投放/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

my.domain.com/v0.3.13.3 should serve /v0.3.13.3/index.html
my.domain.com/v0.3.13.3/dashboard should serve /v0.3.13.3/index.html
my.domain.com/v0.3.13.3/fr should serve /v0.3.13.3/fr/index.html
my.domain.com/v0.3.13.3/fr/dashboard should serve /v0.3.13.3/fr/index.html

我已经设法通过 Azure标准规则引擎做到了这一点,如下面的屏幕截图所示.

I've managed to do it with Azure Standard Rules Engine like the screen shot below.

但是据我从文档中所见,在标准规则引擎中, Contains 字段不能用正则表达式填充.我在Google各处进行了挖掘,但似乎找不到适合我的解决方案.

But as far as i've seen from the docs, in standard rules engine Contains field can't be filled with regex. I've digged all over google but can't seem to find any solution that suits me.

因此,我已将CDN服务切换到Verizon Premium,并尝试应用(v(?:(\ d +)\.)?(?:(\ d +)\.)?(?:(\d +)\.\ d +))到路径正则表达式.

So i've switched my CDN service to Verizon Premium and tried to apply (v(?:(\d+)\.)?(?:(\d+)\.)?(?:(\d+)\.\d+)) to path regex.

Verizon Premium的主要问题在于,如果我将IF字段声明为始终"

The main issue i'm having with Verizon Premium is that i can only apply URL Rewrite feature if i state my IF field to Always

如您所见,未列出 URL Rewrite .

我还使用 Always 语句进行了几次部署,但效果不佳.

Also i've made couple of deployments using Always statement but they did not any good.

每个人在博客中共享的单个示例

The single example that everyone shares in their blogs

因此上述示例未涵盖文件扩展名和子路由.

So above example does not cover File Extensions and sub routes.

有什么方法可以实现我的目标?

Are there any ways to achieve my goal?

谢谢.

推荐答案

我将分享我在规则V4中在Verizon Premium中使用的当前配置:这些步骤是:

I would share my current config that I using in Verizon Premium in Rule V4: The steps are:

  1. 新规则:始终将军
  2. 功能:URL->网址重写
  3. 来源:/80XXXXXX/XXXXXX/((?:[^ \?] */)?)($ | \?.*)
  4. 目的地:/80XXXXXX/XXXXXX/index.html$2
  5. 并添加第二条规则.来源:/80XXXXXX/XXXXXX/((?:[^\?]*\/)?[^\?\/.]+)($ | \?.*)
  6. 目的地:/80XXXXXX/XXXXXX/index.html$2

您还可以按照此处 https://stackoverflow.com/a/58700538/3591687 中的说明获取原点.

Also you can obtainer the origin as described in here 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>

我希望这对某人有帮助

这篇关于用于存储静态网站子目录的Azure CDN Premium Verizon规则引擎V4 URL重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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