How do I rewrite the path of my link with my custom domain?

Question:
How do I rewrite the path of my link with my custom domain? In other words, how do I make my custom domain not have “.html” at the end of the hyperlink? Think something like mod_rewrite but for Repl
Repl link:

code snippet

Hi @j4db2tgd5z , welcome to the forums!
To do this, you’ll have to use app routes.
A backend server (Python, Node.js) will have to be used, paired with a web framework (Flask, Express).
I made a tutorial about this, using Python and HTML.
Link: https://replit.com/@NateDhaliwal/Flask-tutorial-Basics-and-Advanced?v=1

Hope this helps!

Hi @j4db2tgd5z !
You can also take a look at this topic:

Hope this helps!

Hi and welcome! I don’t think you got the link to your repl into the question but an alternative simple option that depends on the footprint of the site is to use directories with an index.html in each. For example, if you could use the following file structure:

Index.html
about/index.html
contact/index.html

And that would support:

example.site/
example.site/about/
example.site/contact/

4 Likes

Welcome to the forums, @j4db2tgd5z!
There are a few ways to do this.

  1. You could do what @NateDhaliwal said about using a backend such as Flask.
  2. You could also use a GitHub Repository, as GitHub allows the use of .htaccess files. Check out this wiki on how to use a Git Repo: How To Connect A Git Repo to your Repl! - General - Replit Ask
  3. Finally, you can also make a folder with the name of the url path you want to use and put a index.html file within that folder. That will allow you to access a URL at for example, example.com/hello instead of example.com/hello.html

Feel free to ask me if you need some help!

1 Like

I think the best way is just making a folder called the page name e.g. about and then putting your file in the folder, renaming it to index.html. Here’s why this works:

When you name your file index.html, you’re able to go to myexamplesite.com and see it. This is because index is the name of the default HTML that is a folder navigation. But since you replace that HTML file, it leads to yours when you go to the root directory. The same thing works within folders. Usually if you had a folder named about and went to /about, it would list all files in about. But adding an index.html in there replaces that page, essentially making your URLs have no file extension.

1 Like