1

The Goal: redirect www.example.com/product/* to www.example.com/product using Google Domains

Background: I'm using github pages to host my site so I cannot add an .htaccess file like a more traditional site. Also I had some issues with emails from my domain going to spam when I used Cloudflare.

There doesn't seem to be an option to simply set up wildcard redirects for paths, just for subdomains.

0

1 Answer 1

3

It isn't possible to set up redirects for some paths but not others using your domain registrar or DNS host. You have to implement any redirects on your web host (github pages).

In fact, it isn't possible to implement redirects without a webserver at all. Even if your domain registrar offers to redirect your domain, it does so by pointing the domain to its own web server and configuring its own webserver to issue the redirects for the domain.

The reason that it isn't possible to use DNS to redirect some path but not others is that DNS points the whole domain to one web server. You can't use DNS to specify different servers for different paths. It's all or nothing.

You have several options:

  1. Create simple pages for each product page you want to redirect and upload them to Github pages. Each page would contain a meta refresh that would direct browsers to redirect: <meta http-equiv="refresh" content="0;url=https://www.example.com/product" /> . For full details see: Redirect a GitHub Pages site with this HTTP hack | Opensource.com

  2. Move web hosts. I don't recommend using Github pages because they don't provide a way to do SEO friendly "301 permanent" redirects. Almost all other web hosts would allow you to properly configure redirects. You could move your site to another web host that supports such functionality.

  3. Use a content delivery network (CDN) and configure the redirects using it. A CDN acts as a front-end reverse-proxy server for your website. Each user fetches your site from an edge node owned by the CDN that is geographically near to the user. If the edge node doesn't have the content, it fetches it from your origin server (which would be github pages) and caches it for the next user. This gives the CDN the ability to add rules for paths as it sits between your users and your web server. For example you could configure page rules on Cloudflare

    A CDN shouldn't make your email end up in spam folders if it is configured correctly. The CDN takes over your DNS hosting, so you would make sure that all of your DNS records get migrated to it. Pay special attention to your MX and TXT records for email. The MX records say which server receives your email and the SPF and DKIM TXT records say which servers are allowed to send mail from your domain. All of those records usually get copied to the CDN DNS unaltered.

2
  • thanks for the info. I added the page rules with cloudflare for the github pages solution, but I think I'm just gonna move to Netlify since it has so many more features and less restrictions.
    – Edward
    Commented Apr 6, 2021 at 17:40
  • also thank you for a complete explanation of everything without the typical SO replies of asking why I would want to do something like this or throwing a console error like a line of javascript when I used the wrong jargon.
    – Edward
    Commented Apr 6, 2021 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.