我有一个Apache的反向代理,我试图做一个规则redirectexample2的几个url到example1,但我的重写规则不起作用。
我已经在example2的虚拟主机中尝试了这一点:
ProxyPass / https://example1.com/index2.html ProxyPassMatch ^[A-Za-z0-9]$ https://example1.com/news-$1
第一个规则的工作,但不是第二个与ProxyPassMatch,当我去https://example2.com/1test05 ,返回一个404错误,但直接访问https://example1.com/news-1test05工作。
任何想法?
因为你的正则expression式不匹配。
^[A-Za-z0-9]$匹配由一个字母数字字符组成的URI,并且您没有放置任何前导斜杠或捕获组。
您需要ProxyPassMatch ^/([A-Za-z0-9]+)$ https://example1.com/news-$1 。