Search code examples
gitlabgitlab-cigitlab-pages

Redirect project url to custom domain


I publish my project to GitLab Pages and add my custom domain. Now I want to redirect the default GitLab url username.gitlab.io/project to my domain name mydomain.com. I add two records in DNS as below:

www.mydomain.com  CNAME  mydomian.com
www.mydomain.com  CNAME  username.gitlab.io/project

but it dosen’t work. How should I do?


Solution

  • If you look at an url, for example: http://example.net/foo/bar the domain name is only the example.net part.

    DNS only controls domain names, so you will not be able to use CNAME records to point to subdirectories on the target domain.

    To do something like that, you would need a webserver which proxies requests to that directory. (Search for nginx reverse-proxy for some examples)