![How to configure Sub-folders with Next.js on Feather](https://cdn.feather.blog?src=https%3A%2F%2Fwww.notion.so%2Fimage%2Fhttps%3A%252F%252Fprod-files-secure.s3.us-west-2.amazonaws.com%252F1631a2ee-6541-4fd1-b6c5-e6268d8d6829%252F7c34a0ca-9c92-47a9-9949-829512a8dbb9%252FFeather_(5).png%3Ftable%3Dblock%26id%3Dba2d1817-6eab-4d0a-931a-c30363239943%26cache%3Dv2&optimizer=image&quality=80&width=280)
Do not index
Do not index
Let’s say your main domain is
www.mydomain.com
and feather blog url is my-domain.feather.blog
and you want to host on /blog
sub-folder.To configure that, add this to your
next.config.js
. Make sure to change my-domain.feather.blog
by your Feather blog url/** @type {import('next').NextConfig} */
const nextConfig = {
rewrites: async () => {
return {
beforeFiles: [
{
source: '/blog',
destination: 'https://my-domain.feather.blog/blog',
},
{
source: '/blog/:path*',
destination: 'https://my-domain.feather.blog/blog/:path*',
},
{
source: '/_feather',
destination: 'https://my-domain.feather.blog/_feather',
},
{
source: '/_feather/:path*',
destination: 'https://my-domain.feather.blog/_feather/:path*',
},
],
}
},
headers: async () => {
return [
{
source: '/blog',
headers: [
{
key: 'X-Forwarded-Host',
value: 'www.mydomain.com',
},
],
},
{
source: '/blog/:slug*',
headers: [
{
key: 'X-Forwarded-Host',
value: 'www.mydomain.com',
},
],
},
{
source: '/_feather',
headers: [
{
key: 'X-Forwarded-Host',
value: 'www.mydomain.com',
},
],
},
{
source: '/_feather/:slug*',
headers: [
{
key: 'X-Forwarded-Host',
value: 'www.mydomain.com',
},
],
},
]
},
}
module.exports = nextConfig
By making the following change, we’re basically telling that:
”Hey Next.js, whenever a person goes to
www.mydomain.com/blog
, don’t do anything. Let feather handle it.”Once this is done, go to Feather. Navigate to Settings > Features and switch on “Enable Subdirectory” feature and after that go to Settings > Sub-folder management and enter the following values,
![notion image](https://cdn.feather.blog?src=https%3A%2F%2Fusenotioncms.com%2Fproxy-prod%2Fblock%2F68c7db94-6340-4792-9b22-b28e0eb50ccd%2F1631a2ee-6541-4fd1-b6c5-e6268d8d6829%2Fe035d350-79c9-4d65-808e-b95064c6b424%2FCleanShot_2024-06-22_at_18.05.282x.png&optimizer=image&quality=80&width=280)
Make sure to replace
www.mydomain.com
with the domain you are using and blog
with whatever sub-route you plan to use.Important Note: Under the Domains section make sure that you are using Subdomain settings. If you have added a custom domain there, please remove it. Sub-folders does not require the Custom Domain configurations and if you have it, then the sub-folder will not work.
Once you do these, your sub-folder should be live. You should be able to access your feather site on
www.mydomain.com/blog
. If it’s not reach out to us at support@feather.so.