#(fixed)
1 messages · Page 1 of 1 (latest)
Yes, there are a few ways to host a page at "/secret" instead of "/secret.html" on your Vercel deployment. Here are some approaches you can use:
1. Create a folder structure
The simplest approach is to create a folder named "secret" and place an "index.html" file inside it:
/
├── index.html
└── secret/
└── index.html
This way, when someone visits "https://unknowinglyexists.vercel.app/secret", Vercel will serve the index.html file from the secret folder.
2. Use a vercel.json configuration file
You can create a vercel.json file in your project root with rewrites to handle this:
{
"rewrites": [
{
"source": "/secret",
"destination": "/secret.html"
}
]
}
This configuration will rewrite requests to "/secret" to serve your "secret.html" file. Vite on Vercel documentation shows a similar approach for handling routes.
3. Using Next.js Pages Router
If you're using Next.js, you can create a file structure in the pages directory:
pages/
├── index.js
└── secret.js
Next.js will automatically route "/secret" to your secret.js component. As explained in the Pages and Layouts documentation, "each page is associated with a route based on its file name."
4. Custom 404 handling
If you're experiencing 404 errors, make sure your project configuration is correct. Check your Output Directory settings to ensure Vercel is serving files from the correct folder.
For more complex routing needs, you might want to consider using a framework like Next.js which provides more robust routing capabilities out of the box.
I hope this helps with your subpage issue!
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@versed parcel Kapa.ai is still learning and improving, please let me know how I did by reacting below.
tysm