Seo optimisation - fix redirects#34
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hotfix for a redirect loop on
/lens/introduced in #33.After the SEO redirect work shipped,
https://weeforest.org/lens/returned ERR_TOO_MANY_REDIRECTS. The root cause was anapp.get('/lens/', …)handler that callednext()on clean requests; the Astro static fallback (extensions: ['html']) then handled the same path and issued another301 → /lens/, looping forever.This PR replaces the Lens
app.getroutes withapp.usemiddleware that only redirects when it should:/lens→/lens/(trailing slash)/lens/?ref=…(and other query variants) →/lens/(strip tracking params)Clean
GET /lens/requests pass through to Lens static and return 200.Context
#33 added Ghost-era URL cleanup and SEO improvements after the Astro migration:
/home/,/author/*, and/sitemap.xmlrobots.txtwithsitemap-index.xml/lens/in the Astro sitemaprobots.txtroute from the Astro distThose changes remain on
main; this PR only fixes the Lens redirect regression.Test plan
curl -sI http://localhost:3939/lens/→ 200curl -sI 'http://localhost:3939/lens?ref=test'→ 301 →/lens/curl -sI 'http://localhost:3939/lens/?ref=test'→ 301 →/lens/http://localhost:3939/lens/loads the mapcurl -sI https://weeforest.org/lens/→ 200curl -sI https://weeforest.org/home/→ 301 →/https://weeforest.org/sitemap-index.xmlin Google Search ConsolePost-deploy (manual)
/lens/loads (not redirect loop).sitemap-index.xml, remove stalesitemap.xmlentry if still present.robots.txt, disable that so originrobots.txtis used.