我只是试图通过更改虚拟主机设置以使用代理设置来将我的 apache 服务器指向 node.js 应用程序,并且当我尝试使 block 通过它匹配所有位置时,它仅匹配具有 1 级深度 url 路径的 url。/example 有效,但/example/damn 不起作用。所以我尝试将正则表达式更改为 Which 甚至有点过分,但我想我会尝试一下,我一直在尝试很多其他正则表达式组合,但没有一个捕获 URL。我可能会补充一点,上面的正则表达式实际上根本不捕获任何内容,它只是在我获取网址时显示我的网站的索引列表。唯一有效的正则表达式是“/*”,但它的深度不会超过 1 个 url/path/anotherpath
我检查了我的正则表达式应该匹配 https://regex101.com/ 处的所有内容但 apache 仍然没有捕获它。
这是我的配置
<VirtualHost *:80>
ServerName my.dev
ServerAdmin ireply@myleisure.com.au
DocumentRoot /home/ggg/Dropbox/host-root/var/www/myleisure.com.au
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
<Proxy "*">
Require all granted
</Proxy>
<Location "(.*)*">
ProxyPass http://localhost:3000
ProxyPassReverse http://localhost:3000
</Location>
</VirtualHost>
最佳答案
这里引用了 Apache 指令配置 documentation page
The directive limits the scope of the enclosed directives by URL, in an identical manner to . However, it takes a regular expression as an argument instead of a simple string.
因此,请尝试使用:
<LocationMatch "(.*)*">
ProxyPass http://localhost:3000
ProxyPassReverse http://localhost:3000
</LocationMatch>
关于node.js - Apache Location 正则表达式不匹配路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43336606/