Webmasters Stack Exchange is a question and answer site for pro webmasters. It only takes a minute to sign up.
Sign up to join this community
Anybody can ask a question
Anybody can answer
The best answers are voted up and rise to the top
The Goal: redirect
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.
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:
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
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.
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
TXTrecords for email. The
MXrecords say which server receives your email and the SPF and DKIM
TXTrecords say which servers are allowed to send mail from your domain. All of those records usually get copied to the CDN DNS unaltered.