0

I have a website written in gatsby and hosted on github. ragith.com does not redirect to www.ragith.com.

For some people ragith.com works for others it directs them to generic page with ads on it. I'm using domain.com for the domain name.

I asked my friend to visit it once, and it didn't work. I asked him to visit again and then it worked. I'm not sure why the website works sometimes and doesn't work other times.

PolarisRouge
  • 395
  • 5
  • 14
  • What's hosting that gatsby site, if you don't mind me asking? Does it have a redirect rule for www? – Abe Apr 24 '20 at 22:06
  • It's being hosted on githubpages. The CNAME has www.ragith.com. There is no rule in the repo to redirect ragith.com to www.ragith.com. I thought this would be done automatically, am I wrong? – PolarisRouge Apr 24 '20 at 22:15
  • Usually you will have your web server handle HTTP redirects for things like this. CNAME doesn't actually handle HTTP redirects. – Abe Apr 24 '20 at 22:29

1 Answers1

0

It sounds like the HTTP redirect is not handled correctly.

You can achieve redirects on github pages in the meta tags of your index.html. This answer tells you how and what to consider

<!DOCTYPE html>
<meta charset="utf-8">
<title>Redirecting to www.ragith.com</title>
<meta http-equiv="refresh" content="0; URL=https://www.ragith.com">
<link rel="canonical" href="https://www.ragith.com">

Regarding building your site and Gatsby, you can set the meta tags with react-helmet. The Gatsby docs tell you how:

import React from "react"
import { Helmet } from "react-helmet"
class Application extends React.Component {
  render() {
    return (
      <div className="application">
        <Helmet>
          <meta charSet="utf-8" />
          <title>My Title</title>
          <link rel="canonical" href="https://www.ragith.com" />
        </Helmet>
      </div>
    )
  }
}
EliteRaceElephant
  • 7,744
  • 4
  • 47
  • 62