【问题标题】:Route two specific urls to a different application apache将两个特定的 url 路由到不同的应用程序 apache
【发布时间】:2016-12-08 23:28:18
【问题描述】:

我有两个应用程序:

  • 为所有域流量提供服务的 WordPress 多站点应用程序
  • Ember 应用仅服务于 /example/path/

在某种程度上,ember 处理到“/example/path/”的流量,但它也处理此后的任何其他路由,例如“/example/path/pretty-wp-page”:

Alias "/example/path" "/var/www/ember/app/dist"

问题是,我希望 ember 只处理到 '/example/path/' 和 '/example/path/another-ember-route' 的流量,而 WordPress 来处理任何其他流量,例如 '/example/path/pretty -wp-page'

我尝试了以下方法:

AliasMatch "/example/path(/|another\-ember\-route)" "/var/www/ember/app/dist"

无济于事。有什么想法或建议吗?我已经用尽了我的技能,在 apache 文档中看不到解决方案,而且 Google 也没有提供任何东西。

谢谢

【问题讨论】:

    标签: regex wordpress apache ember.js


    【解决方案1】:

    试试这个:

    AliasMatch ^/example/path(?:/another-ember-route)?$ /var/www/ember/app/dist
    

    这仅适用于“/example/path”和“/example/path/another-ember-route”。

    解释:

    • 正则表达式路径应始终以 ^ 开头来定义请求的开始,否则它们将对 /whatever/example/path 有效
    • 要指定可能存在或不存在的“可选”内容,您可以使用?在正则表达式中
    • 使用 () 对字符串进行分组,以便稍后使用 ? 将其全部设为可选。
    • 为了正确起见,我在括号中添加了 ?:,这使其成为“非捕获组”,因为您之后不再使用它,但实际上没有必要包含它。
    • 破折号“-”不需要转义
    • 末尾的 $ 表示终止,后面的任何一个都不会匹配,如果删除它,它将匹配 /example/path/whatever。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-03
      • 1970-01-01
      • 1970-01-01
      • 2018-05-03
      • 1970-01-01
      • 2014-08-19
      相关资源
      最近更新 更多