【发布时间】:2018-01-14 04:33:38
【问题描述】:
我在 linux aws ec2 上运行节点 js 服务器。我正在尝试创建一个子域,以便可以在 http://api.domain.com 运行我的节点休息 api。
httpd.conf
<VirtualHost *:80>
ServerName api.domain.com
ProxyPreserveHost On
# setup the proxy
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
</VirtualHost>
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) /server.js
</IfModule>
一切都很好,但是当我尝试点击http://api.domain.com/method 时,它会爆炸。但是http://api.domain//method(强调双 //) 工作正常。如果我只是点击http://api.domain/,我会收到预期的“无法获取 /”错误消息。
另外,http://ip-address:3000/method 工作正常
我假设我需要在我的 .htaccess 文件中添加一些额外的条目或其他内容,但我在那里找不到任何东西...
【问题讨论】: