Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up redirects a little bit #753

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Clean up redirects a little bit
  • Loading branch information
benface committed Aug 22, 2024
commit 007a778cc5ad26dbe39b1907818b94cabc6dc174
16 changes: 9 additions & 7 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ http {
rewrite ^/(.*)//+(.*) $scheme://$http_host/$1/$2 permanent; # remove adjacent slashes in the middle of the URI
rewrite ^/([^.]*[^/])$ $scheme://$http_host/$1/ permanent; # force a trailing slash except for files with an extension

# Permanent redirects (301)
rewrite ^/docs/hostedservice/(.*)$ $scheme://$http_host/docs/en/hosted-service/$1 permanent;
Copy link
Contributor Author

@benface benface Aug 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those /docs/hostedservice/* URLs must be really old; I couldn't find any reference to them anywhere. Also, we deprecated the HS, so I think it's safe to remove this rule.

rewrite ^/docs/(?!(?:[a-zA-Z][a-zA-Z]|_next|img)(?:/|$))(.*)$ $scheme://$http_host/docs/en/$1 permanent; # Redirect to `/en` if no language in URL and not an asset URL
# Redirect to `/en` if no language in URL and not an asset URL
rewrite ^/docs/(?!(?:[a-zA-Z][a-zA-Z]|_next|img)(?:/|$))(.*)$ $scheme://$http_host/docs/en/$1 permanent;

# Permanent redirects (301)
rewrite ^/docs/([a-zA-Z][a-zA-Z])/about/introduction/$ $scheme://$http_host/docs/$1/about/ permanent;
rewrite ^/docs/([a-zA-Z][a-zA-Z])/about/network/$ $scheme://$http_host/docs/$1/network/overview/ permanent;
rewrite ^/docs/([a-zA-Z][a-zA-Z])/curating/$ $scheme://$http_host/docs/$1/network/curating/ permanent;
Expand Down Expand Up @@ -88,14 +88,16 @@ http {
rewrite ^/docs/([a-zA-Z][a-zA-Z])/arbitrum-faq/$ $scheme://$http_host/docs/$1/arbitrum/arbitrum-faq/ permanent;
rewrite ^/docs/([a-zA-Z][a-zA-Z])/cookbook/migrating-a-subgraph/$ $scheme://$http_host/docs/$1/cookbook/upgrading-a-subgraph/ permanent;
rewrite ^/docs/([a-zA-Z][a-zA-Z])/cookbook/quick-start/$ $scheme://$http_host/docs/$1/quick-start/ permanent;
rewrite ^/docs/en/substreams/(?!index\.).+$ https://substreams.streamingfast.io permanent;
rewrite ^/docs/en/firehose/(?!index\.).+$ https://firehose.streamingfast.io permanent;
Comment on lines -91 to -92
Copy link
Contributor Author

@benface benface Aug 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just moved these to the bottom of the list because they're different from the others (English-only).

rewrite ^/docs/([a-zA-Z][a-zA-Z])/developer/assemblyscript-api/$ $scheme://$http_host/docs/$1/developing/graph-ts/api/ permanent;
rewrite ^/docs/([a-zA-Z][a-zA-Z])/developing/assemblyscript-api/$ $scheme://$http_host/docs/$1/developing/graph-ts/api/ permanent;
rewrite ^/docs/([a-zA-Z][a-zA-Z])/managing/deprecating-a-subgraph/$ $scheme://$http_host/docs/$1/managing/transfer-and-deprecate-a-subgraph/ permanent;
rewrite ^/docs/([a-zA-Z][a-zA-Z])/managing/transferring-subgraph-ownership/$ $scheme://$http_host/docs/$1/managing/transfer-and-deprecate-a-subgraph/ permanent;
Comment on lines +93 to +94
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the redirects that should have been included in #741; my bad for not noticing in my review. :)

rewrite ^/docs/en/substreams/(?!index\.).+$ https://substreams.streamingfast.io permanent;
rewrite ^/docs/en/firehose/(?!index\.).+$ https://firehose.streamingfast.io permanent;

# Temporary redirects (302)
rewrite ^/docs/en/querying/graph-client/$ $scheme://$http_host/docs/en/querying/graph-client/README/ redirect;
rewrite ^/docs/en/developing/graph-ts/$ $scheme://$http_host/docs/en/developing/graph-ts/README/ redirect;
rewrite ^/docs/en/querying/graph-client/$ $scheme://$http_host/docs/en/querying/graph-client/README/ redirect;
rewrite ^/docs/en/developing/graph-ts/$ $scheme://$http_host/docs/en/developing/graph-ts/README/ redirect;

location / {
try_files $uri $uri.html $uri/index.html =404;
Expand Down
26 changes: 1 addition & 25 deletions website/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,7 @@ export default withNextra({
destination: '/en/',
permanent: true,
},
{
source: '/en/arbitrum-faq/',
destination: '/en/arbitrum/arbitrum-faq/',
permanent: true,
},
{
source: '/en/querying/graph-client/',
destination: '/en/querying/graph-client/README/',
permanent: false,
},
{
source: '/en/developing/graph-ts/',
destination: '/en/developing/graph-ts/README/',
permanent: false,
},
{
source: '/en/developer/assemblyscript-api/',
destination: '/en/developing/graph-ts/api/',
permanent: true,
},
{
source: '/en/developing/assemblyscript-api/',
destination: '/en/developing/graph-ts/api/',
permanent: true,
},
Comment on lines -59 to -83
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason we ever needed to include redirects here (in addition to nginx.conf) is that there can still be links to the old URLs in the Markdown files. If that is the case, Next needs to be aware of them, otherwise the client-side router will link to a 404 (or maybe attempt to do a full page reload, which would be better, but still not ideal). But I hate having to maintain the same list of redirects in two places, so I went ahead and replaced all the old URLs still lingering around to the new ones, which allows us to remove these.

// If we ever change `output` to not be `export`, we should move all the redirects from `nginx.conf` here
],
images: {
unoptimized: true,
Expand Down
Loading