#How to redirect home page

3 messages · Page 1 of 1 (latest)

mellow sage
#

I've tried defining redirects in astro.config like this:

redirects: {
    "/": "/dashboard",
  },

But it doesn't work. It works for other paths but not for root.

copper warrenBOT
#

Hi @mellow sage. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the knowledge sources provided, there isn't specific information about redirecting the home page ("/") in Astro. However, there is a mention of a redirectToDefaultLocale configuration in the context of internationalization, which redirects the home URL (/) to a default locale URL.

astro@4.2.0
routing: {
  redirectToDefaultLocale: true
}

This configuration is used to redirect the home URL (/) generated by src/pages/index.astro to /<defaultLocale>. If you set prefixDefaultLocale: true, it will also automatically set redirectToDefaultLocale: true in your routing config object. By default, the required src/pages/index.astro file will automatically redirect to the index page of your default locale. You can opt out of this behavior by setting redirectToDefaultLocale: false. This allows you to have a site home page that exists outside of your configured locale folder structure. source (https://docs.astro.build/en/guides/internationalization#redirecttodefaultlocale)

However, this might not be the solution you're looking for if you're not dealing with internationalization.

There have been issues reported with Astro's redirect feature, as seen in these Github issues (https://github.com/withastro/astro/issues/9259) and Github issues (https://github.com/withastro/astro/issues/7322). It's possible that the issue you're experiencing is related.

If you're still having trouble, I recommend checking Astro's official documentation or reaching out to the Astro community for further assistance.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: