question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hello 😃

I am trying to apply 301 redirect with my Gatsby and S3 + Cloudfront , and so far i have no success , i have about 204 redirect url , i will list below my configuration .

fromPath: `/old-url`,
toPath: `/new-url`,
isPermanent: true,
redirectInBrowser: true,
});
`


 {
      resolve: 'gatsby-plugin-s3',
      options: {
        bucketName: process.env.S3_BUCKET,
        region: 'eu-west-1',
        protocol: 'https',
        hostname: 'stage-mydomain.de',
        bucketPrefix: 'de',
        generateRoutingRules: true,
        generateRedirectObjectsForPermanentRedirects: true,
      }
    }

note that i have no plugin related to redirect inside my config , 
what i would like to accomplish is pure 301 server side redirect , i dont want JS redirect and Meta redirect because 
Js will not work with JS disabled and Meta is not good for SEO . 

can someone help please? 
Thanks

> 

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:36

github_iconTop GitHub Comments

6reactions
JoshuaWalshcommented, Nov 11, 2020

Creating a fork duplicates the project into a repository that you own. You can change that freely. If we make updates to our version you can pull those into your repository, and if you make changes that you think we’d like you can submit a Pull Request to us.

In your website’s package.json you have a line that looks something like this:

"gatsby-plugin-s3": "^0.3.8"

If your fork is hosted on GitHub, you can alter this to point to your fork by doing something like:

"gatsby-plugin-s3": "ahmadkhalaf1/gatsby-plugin-s3"

You can find more details here:

Best of luck 😃

4reactions
JoshuaWalshcommented, Nov 16, 2020

302 redirects in S3 Static Website Hosting are usually to add a trailing slash. If you add a trailing slash to your redirect’s toPath it should only need a single 301 redirect.

Thanks for the offer to buy me a beer. We don’t have any mechanism set up for tipping, and I’m just happy that it’s working for you.

Fixing the bug permanently should be fairly straightforward, but first I want guidance from the Gatsby Core team on how they think redirects should be handled. Unfortunately they recently restructured their community, and now it’s harder to get in touch with them. I might try resubmitting my question as a bug instead of a discussion to see if that gets better visibility.

At the moment I’m thinking the best solution would be for us to subtract pathPrefix from the beginning of the fromPath of all redirects, then to add bucketPrefix. This is basically just a workaround for what I consider to be a bug in Gatsby.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is a 301 Redirect, and When Should You Use One?
A 301 signals a permanent redirect from one URL to another, meaning all users that request an old URL will be automatically sent...
Read more >
Redirects: Different types and how to implement them - Moz
A 301 redirect is a permanent redirect that passes full link equity (ranking power) to the redirected page. 301 refers to the HTTP...
Read more >
Redirects and Google Search | Documentation
This is the best way to ensure that Google Search and people are directed to the correct page. The 301 and 308 status...
Read more >
301 Redirects for SEO: Everything You Need to Know - Ahrefs
A 301 redirect indicates the permanent moving of a web page from one location to another. The 301 part refers to the HTTP...
Read more >
How to Create a 301 Redirect - Video - Domain.com
To redirect a site permanently, one should use a 301 redirect. This type of redirect is best for SEO purposes and also informs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found