Issue with Rewrite Configuration on Vercel Leading to 404 Errors for Sub-Pages

Problem Description:

Hello, I have a project that relies on multiple separate HTML pages, and I am facing an issue configuring vercel.json to redirect correctly to these pages. When I try to access a sub-page, like/blogsor /ourServices, I get a 404 (Not Found) error.

Project Link on Vercel: https://digitalize-v-2-p1by.vercel.app

Steps I’ve Taken:
Configured vercel.json: I added rewrite rules in vercel.json to ensure that each path directs to the correct page. I specified each required path manually.

Paths Configured:

/ourServices → Should direct to /digitalize-v.2/ourServices/html/digitalize/service.html
/blogs → Should direct to /digitalize-v.2/blogs/html/digitalize/blogs.html
/blog-details → Should direct to /digitalize-v.2/blogs-details/html/digitalize/blog-details.html

Current vercel.json Configuration:

{

“version”: 2,
“rewrites”: [
{
“source”: “/assets/(.)",
“destination”: “/html/digitalize/assets/$1”
},
{
“source”: “/about”,
“destination”: “/html/digitalize/index.html”
},
{
“source”: “/contact”,
“destination”: “/html/digitalize/index.html”
},
{
“source”: “/ourServices”,
“destination”: “/digitalize-v.2/ourServices/html/digitalize/service.html”
},
{
“source”: “/blogs”,
“destination”: “/digitalize-v.2/blogs/html/digitalize/blogs.html”
},
{
“source”: “/blog-details”,
“destination”: “/digitalize-v.2/blogs-details/html/digitalize/blog-details.html”
},
{
“source”: "/(.
)”,
“destination”: “/html/digitalize/index.html”
}
],
“cleanUrls”: true,
“trailingSlash”: false
}

Here is the link to my GitHub repository:

Deployment Link:

https://digitalize-v-2-p1by-a99n9ezub-fadyfatheys-projects.vercel.app/

Hey @fadyfathey. The first thing I would check is that the paths you’re directing to actually exist. For example, /blogs throws a 404 error because /digitalize-v.2/blogs/html/digitalize/blogs.html doesn’t exist. You can find the build output in the deployment summary or in the Source tab on the deployment details page.

I wrote a longer post with more detail about how to investigate and solve 404 errors. You can find it here: Debugging 404 Errors

It looks like a couple of your other rewrites might also need some adjustments to get them working the way you expect. The Rewrites on Vercel documentation can help with that. :smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.