共享主机上具有子域的Node.js应用的重写规则

时间:2018-08-24 03:31:11

标签: node.js .htaccess shared-hosting

我正在尝试根据A2Hosting上的本教程在共享主机上运行nodejs应用程序并成功安装node / npm:

https://www.a2hosting.com/kb/installable-applications/manual-installations/installing-node-js-on-managed-hosting-accounts

我现在正在将NODE.JS应用程序与Web服务器部分集成在一起,当我将重写规则复制到.htaccess文件时,它将在根域而不是wordpress网站上运行该节点。这是我的.htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

# BEGIN Node
# RewriteRule ^$ http://127.0.0.1:49876/ [P,L]
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^(.*)$ http://127.0.0.1:49876/$1 [P,L]
# END Node

我希望nodejs应用程序可以在subdomain之类的子域上运行:subdomain.domain.com,并保持wordpress在domain.com上运行

我应该对nodejs重写规则进行哪些更改以使其在子域上运行。

0 个答案:

没有答案