【问题标题】:RedirectMatch > regex重定向匹配 > 正则表达式
【发布时间】:2016-09-08 20:37:02
【问题描述】:

任何想法为什么这不起作用?

.htaccess 文件中的 RedirectMatch 规则。

RedirectMatch "(?:example.com)\/(?:images)\/(.*)(jp?g|bmp|png)" "http://www.example.com/assets/images/public/$1 $2"

我感觉归结为正则表达式不正确。

期望的结果: 基本上,如果请求: http://www.example.com/images/some-logo.jpg 它是从这里拉出来的: http://www.example.com/assets/images/public/some-logo.jpg

【问题讨论】:

    标签: regex apache .htaccess


    【解决方案1】:

    我认为您需要RewriteRule 而不是RedirectMatch

    RewriteRule ^images/([^/]+)$ /assets/images/public/$1 [L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多