Remove Extensions from Sub-Pages

html
#1

Hey so, I’m wondering on how I could remove the extensions from my sub pages thanks.

https://ipexs-site.glitch.me/pages/1.html Works

https://ipexs-site.glitch.me/pages/1 Doesn’t Work

#2

This depends a lot on what frameworks you’re using, but if you’re using Node with Express, like the “node-app” starter project, you’ll need to add a route to your server file.

For instance if you look at line 15 in https://glitch.com/edit/#!/hello-express?path=server.js:15:0 , the part that says app.get(“/“...) defines a route for the home page of that app. If you changed “/“ to “index” then what you see at https://hello-express.glitch.me/ would instead show up at https://hello-express.glitch.me/index without any “.html”

This project can show you that.

1 Like
#3

Hey @Ipex I see you’re starting with a hello-webpage-based project. That pattern uses lws for the web server, which can be controlled by a file called lws.config.js at the root of your project (i.e. not in a subfolder). The documentation at https://github.com/lwsjs/local-web-server/wiki might be helpful - you could probably accomplish what you’re looking to do by using redirects as described there.

I also see you attempted to use a .htaccess file to remove the extensions. That won’t work with an lws-based project because lws doesn’t respect .htaccess, but you could start from something like https://glitch.com/~lamp-poc, which starts an Apache web server that will pay attention to .htaccess.

Hope this helps!

1 Like
#4

I’m really confused on what to do @cori.

#5

Ok, assuming that your central goal is to be able to build a site with static web pages (just plain html files) without extensions, and that you’re pretty comfortable with .htaccess, I’ve remixed https://glitch.com/~lamp-poc and added your .htaccess and pages/1.html file to show how to do with with Apache. You can take a look at https://glitch.com/~legendary-scourge and the results at https://legendary-scourge.glitch.me/pages/1

The “magic” starts in glitch.json, which tells Glitch to run the scripts referenced there. Then lamp-start.sh tells Glitch to start up Apache (the important bits of which are in the .apache2 folder that was copied over from https://glitch.com/~lamp-poc).

Hopefully that will help get you on your way, but let me know if you have further questions!

1 Like