I have a custom domain abhijeetsaxena.in configured for my netlify account.I remember I had also properly setup the redirect behavior such that it used to properly redirect gh-pages site to my netlify homepage site without any issues. For few repositories, it seems to work fine but for a recent project I created, when I got to my custom domain it just redirects to gh-pages url
For example,
https://github.com/abhijeet-saxena/wysiwyg this repository has a gh-pages site but when I go to WYSIWYG Editor it renders properly without changing URL
[[redirects]]
from = '/*'
to = 'https://abhijeet-saxena.github.io/:splat'
status = 200
[[headers]]
for = "/*"
[headers.values]
X-Frame-Options = "SAMEORIGIN"
X-XSS-Protection = "0"
X-Content-Type-Options = "nosniff"
Content-Security-Policy = "default-src 'self'; style-src 'self'; form-action 'self'; script-src 'self'; connect-src 'self'; img-src 'self'; base-uri 'self';"
I tried to go through the docs and see if I can find something but as its working fine for few sites and not working for one I’m not exactly sure if its a config thing or something else. Kindly help.
These redirects have been in place since September 2021.
Site Name: abhijeet-saxena API ID: 105cf054-6128-4e73-b552-2ec02ff03441
This is the main site that corresponds to my gh-pages homepage at GitHub - abhijeet-saxena/abhijeet-saxena: My Personal Site
So technically any project under my GitHub and deployed on gh-pages should also be available as a subpath after my custom domain.
I think I know what the issue is, I noticed that a trailing slash leads to proper behavior.
For example, https://abhijeetsaxena.in/wordle/ behaves correctly, but when I use https://abhijeetsaxena.in/wordle it redirects to https://abhijeet-saxena.github.io/wordle/ which is not what I want.
@coelmay Actually, I have multiple projects, so I was trying to handle this all at once. Will I need to setup redirects for each of my projects in github ?
Also, I tried to add the suggested redirect to my netlify.toml file but doesn’t seem to make any difference
[[redirects]]
from = '/wordle/*'
to = 'https://abhijeet-saxena.github.io/wordle/:splat'
status = 200
[[redirects]]
from = '/*'
to = 'https://abhijeet-saxena.github.io/:splat'
status = 200
[[headers]]
for = "/*"
[headers.values]
X-Frame-Options = "SAMEORIGIN"
X-XSS-Protection = "0"
X-Content-Type-Options = "nosniff"
Content-Security-Policy = "default-src 'self'; style-src 'self'; form-action 'self'; script-src 'self'; connect-src 'self'; img-src 'self'; base-uri 'self';"
I added these redirects to a test site. Browsing to /wordle/ loads fine. But unlike your site /wordle does not redirect, rather it fails to load page resources as it is looking at the site root. This is fixable with <base>.
This behaviour is the same using https://abhijeetsaxena.in/wordle/ vs https://abhijeetsaxena.in/wordle too when I try a different browser (redirect is likely cached now.) Can you try a different browser to see what result you get.
@coelmay Yup, you’re right. In a different browser, it is working. I did have to set the correct <base> to import the assets from the right path.
Can you suggest a way in which I can handle this for multiple projects without cluttering up my netlify.toml file with each redirect rule? Because everytime I create a new project on gh-pages I’ll also have to handle that in the config