Skip to content

Commit

Permalink
Allow subdomain to redirect in Netlify
Browse files Browse the repository at this point in the history
link to channel via _redirects and CNAME thanks to Chris:

Hi Rob,

CNAMEs can only point to hostnames, not paths.  So you won't be able
to make "channel.marbletrack3.com" point to anything more specific
than "youtube.com" that way.  Redirects probably is the way to go -
those can point wherever.  Something like this should work.

set domain alias for channel.marbletrack3.com on a site you already
have here (that's like adding another custom domain, in the same place
in the Domain config) set up DNS of channel.marbletrack3.com CNAME
pointing to wonderful-bhabha-dfd1ef.netlify.com (yup, same place as www)

add this redirect to _redirects:
https://channel.marbletrack3.com/* https://youtube.com/channel/mygreatchannel 301!

On Wed, Oct 17, 2018 at 05:04 PM, "Rob Nugen" wrote:

> be me
> move site to Netlify
> oh no subdomains broke
> try _redirect
> no good
> create CNAME
> https://app.netlify.com/account/dns/marbletrack3.com

channel.marbletrack3.com --> youtube.com/channel/mygreatchannel

> wait an hour
> refresh still not working
> use greentext for support
> refresh still not working

<whatdo.gif>
  • Loading branch information
thunderrabbit committed Oct 18, 2018
1 parent 1b5a964 commit e465162
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions _redirects
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Redirect default Netlify subdomain to primary domain
http://wonderful-bhabha-dfd1ef.netlify.com/* http://www.marbletrack3.com/:splat 301!
http://channel.marbletrack3.com/* https://www.youtube.com/channel/UCHiQhB8J_KI2LYQ7dsexfLw 301!
https://channel.marbletrack3.com/* https://www.youtube.com/channel/UCHiQhB8J_KI2LYQ7dsexfLw 301!

2 comments on commit e465162

@thunderrabbit
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note, this commit has the _redirects file in the root of the project, which does not work. I moved it to static/ so Hugo would put it in the public output folder.

Better solution might be to use netlify.toml which can be in the root, but I will leave this for now.

(haha "for now")

@thunderrabbit
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Created #2

Please sign in to comment.