Showing a GitHub project page only under custom subdomain, never via folder path

强颜欢笑 提交于 2019-12-23 02:19:27

问题


I have an organization GitHub Pages repository set up, and it's served through a custom domain name (let's say, http://example.com/).

I also have a couple of projects pages which I want to be accessible via a subdomain only (let's say, http://project.example.com/), but it turns out that they will also be accessible at a different URL (that is, http://example.com/projectname/).

Is there any way to avoid this? Both the organization pages and the project pages have CNAME entries set up, and the DNS records seem to be correctly configured.


回答1:


http://project.example.com/ will also be accessible at http://example.com/projectname/

> Is there any way to avoid this?

I was able to avoid this via a project pages setup for each subdomain as well as the domain. It didn't work with CNAME records so I had to use A records in the server side configuration. Every record would point to the Github IPs 192.30.252.153 and 192.30.252.154, using the subdomain as host or @ for the domain.com part.

For future users looking into how to map a Github page to a domain / subdomain:

  1. Create new Github repo and add a gh-pages branch.
  2. Add your index.html and a CNAME file with only one line sub.domain.tld.

See this gist for more details.




回答2:


The only solution that I am aware of is hiding http://domain.tld/projectname/ content with a robots.txt file on the web server that serves that domain.

http://en.wikipedia.org/wiki/Robots_exclusion_standard



来源:https://stackoverflow.com/questions/17913321/showing-a-github-project-page-only-under-custom-subdomain-never-via-folder-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!