仅在自定义子域下显示GitHub项目页面,绝不通过文件夹路径 [英] Showing a GitHub project page only under custom subdomain, never via folder path
问题描述
我有一个组织GitHub Pages存储库设置,它通过一个自定义域名(比如 Github回购并添加 gh-pages
分支。
index.html
和仅包含一行的CNAME文件 sub.domain.tld
。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.
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.
这篇关于仅在自定义子域下显示GitHub项目页面,绝不通过文件夹路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!