In the past, BitBucket allowed CNAME to use custom subdomains like hg.yourdomain.tld. But recently, Atlassian decided to remove this feature,
You can drop the DNS record and update your documentation, but that will be a violation of Cool URIs don’t change and you can’t update paper documentation, bookmark from other users, etc.
If you want to keep these URL workings, you can create a server block in nginx and provide location blocks to redirect all the traffic from sub.yourdomain.tld
to bitbucket.org/<account or team name>
.
1 2 3 |
location / { return 301 https://bitbucket.org/dereckson$request_uri; } |
You can also take this opportunity to migrate Mercurial repositories to Git if you’ve only used your own URL.
In this example,I renamed the Mercurial zed repository as zed-hg, redirected legacy URLs to legacy Mercurial repository:
1 2 3 4 |
# hg.dereckson.be/zed repository has been renamed zed-hg location ~ ^/zed(/?.*)$ { return 301 https://bitbucket.org/dereckson/zed-hg$1; } |
Use a regular expression starting by /yourrepository to catch the remaining of the request. Remember the final slash is facultative, and so the request can be captured as (/?*.)
instead of /(.*)
.