Skip to content
Sign upLog in
← Back to Community

Can we make custom 404 pages on repl.it>

Profile icon
205135tmd

I have a basic acount, I haven't upgraded or anything like that.
With that being said, are we able to make custom 404 pages with .htaccess, on repl.it?
cuz, I tried to do that by watching videos and reading on how to do it. Nothing works.

Answered by SixBeeps [earned 5 cycles]
View Answer
Voters
Profile icon
SandunWira
Profile icon
205135tmd
Comments
hotnewtop
Profile icon
SixBeeps

htaccess is an Apache thing, so unless you did some custom routing (I think you can do it with Django, not sure about any other frameworks) that's gonna be a no. Upgraded plan won't give you that functionality either.

EDIT: You can do it with Node: https://stackoverflow.com/questions/6528876/how-to-redirect-404-errors-to-a-page-in-expressjs

Profile icon
HGStyleOfficial

@SixBeeps
i have a website working on HTML. Can I do a 404 page ?

Profile icon
CoolCoderSJ

hey there,
Heres how i did it.

Things to know before u do this

  • It wouldn't be an HTML repl, rather a node.js repl
  • you need to use something to keep your node.js server running, I used Cron Jobs
  1. Download your HTML repl as a zip and unzip it.
  2. Make a new Node.js repl and upload the unzipped folder.
  3. Rename that uploaded folder to public
  4. At this point, make sure index.js , 404.html and README.md (if u have one) are in root. All other files should be in /public, including 404.js, 404.css, and index.html.
  5. Inside of index.js (The one in root. You should have 2 js indexes, one in /index.js and one in /public/index.js. The second one supports index.html, whereas the first one supports the server.) Enter this code
require("express")().use(require("express").static(__dirname + "/public")).use((_, res) => { res.status(404).sendFile(__dirname + "/404.html"); }).listen(8080);

this should bring up your website.

Now we gotta keep the server alive

I used Cron Jobs
Once you login/signup, go to cronjobs. Make a new cron job. Enter your website domain in the first field. Unmark HTTP authentication. Set it to run every 1 minute. Save.

Voila!

Note: Every time you wanna update the website, stop the repl and re run. if its not currently running, the website wont load.

This worked for me, and I hope it worked for you too. please upvote/mark this as correct If it did.

Profile icon
StudioHawaii

idk