{"id":725,"date":"2015-01-08T03:13:46","date_gmt":"2015-01-08T02:13:46","guid":{"rendered":"https:\/\/www.dereckson.be\/blog\/?p=725"},"modified":"2018-04-09T03:31:06","modified_gmt":"2018-04-09T01:31:06","slug":"bitbucket-wont-serve-cname-anymore-how-to-keep-urls-working","status":"publish","type":"post","link":"https:\/\/www.dereckson.be\/blog\/2015\/01\/08\/bitbucket-wont-serve-cname-anymore-how-to-keep-urls-working\/","title":{"rendered":"Bitbucket won&#8217;t serve CNAME anymore, how to keep URLs working?"},"content":{"rendered":"<p>In the past, BitBucket allowed CNAME to use custom subdomains like hg.yourdomain.tld. But recently,\u00a0Atlassian <a href=\"https:\/\/confluence.atlassian.com\/x\/Eg4zDQ\">decided to remove this feature<\/a>,<\/p>\n<p>You can drop the DNS record and update your documentation, but that will be a violation of\u00a0<a href=\"https:\/\/www.w3.org\/Provider\/Style\/URI\">Cool URIs don&#8217;t change<\/a> and you can&#8217;t update paper documentation, bookmark from other users, etc.<\/p>\n<p>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 <code>sub.yourdomain.tld<\/code> to <code>bitbucket.org\/&lt;account or team name&gt;<\/code>.<\/p>\n<pre class=\"lang:default decode:true\" title=\"nginx configuration for hg.dereckson.be\">location \/ {\r\n\u00a0 \u00a0 return 301 https:\/\/bitbucket.org\/dereckson$request_uri;\r\n}<\/pre>\n<p>You can also take this opportunity to migrate Mercurial repositories to Git if you&#8217;ve only used your own URL.<\/p>\n<p>In this example,I renamed the Mercurial zed repository as zed-hg, redirected legacy URLs to legacy Mercurial repository:<\/p>\n<pre class=\"lang:default decode:true\" title=\"nginx configuration for hg.dereckson.be\"># hg.dereckson.be\/zed repository has been renamed zed-hg\r\nlocation ~ ^\/zed(\/?.*)$ {\r\n    return 301 https:\/\/bitbucket.org\/dereckson\/zed-hg$1;\r\n}<\/pre>\n<p>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 <code>(\/?*.)<\/code> instead of <code>\/(.*)<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the past, BitBucket allowed CNAME to use custom subdomains like hg.yourdomain.tld. But recently,\u00a0Atlassian decided to remove this feature, You can drop the DNS record and update your documentation, but that will be a violation of\u00a0Cool URIs don&#8217;t change and you can&#8217;t update paper documentation, bookmark from other users, etc. If you want to keep [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49,45,50],"tags":[325,101],"class_list":["post-725","post","type-post","status-publish","format-standard","hentry","category-dev","category-misc","category-sysadmin","tag-bitbucket","tag-nginx"],"_links":{"self":[{"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/posts\/725","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/comments?post=725"}],"version-history":[{"count":3,"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/posts\/725\/revisions"}],"predecessor-version":[{"id":728,"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/posts\/725\/revisions\/728"}],"wp:attachment":[{"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/media?parent=725"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/categories?post=725"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dereckson.be\/blog\/wp-json\/wp\/v2\/tags?post=725"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}