Hello,
I have installed NodeJS onto my cPanel account, then I uploaded my NodeJS website/app onto my public_html/website then I added the following code to my htaccess:
RewriteEngine On
RewriteRule ^$ http:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^$ http:
After adding that code to .htaccess, I ran the NodeJS application, and the website ran, and the homepage looked fine and all there, but when I go to any other pages, like for an example go to the About me page, It shows Not Found The requested URL /about was not found on this server.
[404 not found picture][1]
Then I proceeded to make a slight change in the .htaccess:"**^$**" to "**^(.*)$**" in the last line
RewriteEngine On
RewriteRule ^$ http:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http:
This caused the website to through an error showing: "404: index.php" and the homepage loaded but was missing a lot of stuff, BUT! the other pages showed but not fully there.. here is an image of the homepage: [homepage after tweak][2] and here's a picture of the second page that was showing 404 before the tweaking: [second page][3]
I have been researching non stop and I still can't find the solution, but here is my nodejs execution code:
var createError = require('http-errors');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var mongoose =require('mongoose');
var methodOverride = require('method-override');
var nodemailer = require('nodemailer');
mongoose.connect('mongodb://jhad96:jhad96@ds121268.mlab.com:21268/hoca');
mongoose.Promise = global.Promise;
var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
var app = express();
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(methodOverride("_method"));
app.use(express.static(path.join(__dirname, 'public')));
app.use('/uploads',express.static(path.join(__dirname, 'uploads')));
app.use('/', indexRouter);
app.use('/users', usersRouter);
app.use(function(req, res, next) {
next(createError(404));
});
app.use(function(err, req, res, next) {
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
res.status(err.status || 500);
res.render('error');
});
app.listen(process.env.PORT || 51521, ()=>{
console.log('server is on ');
});
Here is a picture of the nodejs website files: [files][4]
[1]: https://i.stack.imgur.com/hwsyS.png
[2]: https://i.stack.imgur.com/sqds1.png
[3]: https://i.stack.imgur.com/dsZOi.png
[4]: https://i.stack.imgur.com/gjOAr.png
I really appreciate your help guys :)
much love
What I have tried:
seems that I have tried everything.. :/