不断收到错误503-A2Hosting上的Node.js应用 [英] Keep Getting Error 503 - Node.js app on A2Hosting
问题描述
我有一个节点应用程序,可以在Heroku上完美运行,但不能在A2Hosting或FastComet上运行:
I have a node app that works perfectly on Heroku but not on A2Hosting nor on FastComet:
这是一个使用ejs的快速应用程序.
It is an express app using ejs.
路线简单如下:
//Root Route
app.get("/", function(req, res){
res.render("index");
});
app.get("/contact", function(req, res){
// res.send("You have reached the contact page");
res.render("contact");
});
app.get("/about", function(req, res){
// res.send("You have reached the contact page");
res.render("about");
});
我在联系和路线上始终收到错误503,但初始index.ejs正常运行:
I keep getting an error 503 on the contact and about routes but the initial index.ejs works just fine:
我的.htaccess文件仅是以下内容:
My .htaccess file is simply the following:
RewriteEngine On
RewriteRule ^$ http://127.0.0.1:49555/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:49555/$1 [P,L]
DirectoryIndex views/index.ejs
该应用程序可以在我的本地主机以及Heroku上完美运行.我已经尝试了所有方法,但似乎无法正确显示我与contact.ejs和about.ejs的链接.
The App works perfectly on my localhost as well as on Heroku. I have tried everything and cannot seem to come right with my links to contact.ejs and about.ejs.
标签很简单:
<nav>
<li><a href="/about">Samples</a> </li>
<li><a href="/contact">Contact</a> </li>
</nav>
Index.ejs,contact.ejs和about.ejs在视图文件夹中.
The Index.ejs, contact.ejs and about.ejs are in a views folder.
这是A2Hosting上的实际站点: http://www.digital-alchemy.solutions
This is the actual site on A2Hosting: http://www.digital-alchemy.solutions
这是Heroku上运行良好的网站: https://desolate-lowlands-92367.herokuapp.com
And This is the site on Heroku which works perfectly: https://desolate-lowlands-92367.herokuapp.com
任何帮助将不胜感激.
亲切的问候
韦恩
推荐答案
在A2Hosting支持人员的大力帮助下,问题在于.htaccess文件中缺少一行.
With amazing help from A2Hosting support staff, the problem was a missing line in the .htaccess file.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ views/$1.ejs [NC,L] <<<< This line was missing
RewriteEngine On
RewriteRule ^$ http://127.0.0.1:49555/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:49555/$1 [P,L]
DirectoryIndex views/index.ejs
这篇关于不断收到错误503-A2Hosting上的Node.js应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!