您应该使用Apache mod_proxy而不是mod_rewrite在Apache中运行Node.js应用程序:
<VirtualHost :80> ServerName example.com ProxyRequests off <Proxy *> Order deny,allow Allow from all </Proxy> <Location /myapp> ProxyPass http://localhost:61000/ ProxyPassReverse http://localhost:61000/ </Location></VirtualHost>
如果您无法为Node应用添加虚拟主机,则可以尝试使用htaccess和类似的方法:
RewriteEngine onRewriteRule ^/myapp$ http://127.0.0.1:61000/ [P,L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^/myapp/(.*)$ http://127.0.0.1:61000/$1 [P,L]


