Can you use .htacces on glitch?

I use glitch for making HTML website and want to create a custom 404 and 403 page. Is it possible to use .htacess on Glitch?

1 Like

Let’s take a step back to answer your question.

.htaccess files are configuration files for web servers running Apache. The typical setup for Glitch projects serve their webpages via a Node.js web application framework called Express. For such projects, Express serves the same purpose as Apache.

To answer your question: without putting in a bit of work, .htaccess files are useless on Glitch. Express handles things programmatically compared to Apache, which is more configuration-based. That being said, there are more than a few npm packages for Express configuration. It looks like there’s even one for parsing .htaccess files (but it looks like it might be out of date).

I suggest you find a suitable package for Express configuration—not necessarily one capable of parsing .htaccess files—and work from there. Different technologies sometimes have different usage patterns, especially in the sense of the technologies being more “opinionated” than others. In this case, both Express and Apache are somewhat opinionated when it comes to configuration.

EDIT: It’s 2020, old man! Times change and so do answers! See this post for some more information on how to use Apache in Glitch.

3 Likes

So I decided to go back to this thread because this was a while back (this was my first post on the Glitch forum, crazy, I know right?).

I have learned a lot since this post and wanted to say that there is an Apache server on Glitch (that yes, can use .htaccess). I use it for many of my projects and it works just fine. Link here.

2 Likes

Oh cool! You can also make a 404 page with express; just check if the website url/server is a website that is not listed, for example

hi.html is whitelisted, meaning that it is published
and then
*, which is all other things not whitelisted that the user types in.
Use * to respond with your 404 page!

Correct! You can also do this in express!

app.use(function(req, res) {
  res.send('404: Page not Found', 404);
});

https://www.hacksparrow.com/webdev/express/custom-error-pages-404-and-500.html

1 Like

That means I was the first to respond to the golden retriever guy.

Woah.


I’m glad you came back and updated the post. I’ll revise my answer to point to yours accordingly.

1 Like