问题
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:
- Create new Github repo and add a
gh-pages
branch. - Add your
index.html
and a CNAME file with only one linesub.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