# Duplicate http/https topics are randomly created

**URL:** <https://meta.discourse.org/t/duplicate-http-https-topics-are-randomly-created/77190>\
**Category:** Product Support\
**Created:** [January 3, 2018, 8:05pm UTC](https://meta.discourse.org/t/duplicate-http-https-topics-are-randomly-created/77190 "2018-01-03T20:05:29Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![spectrum](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/spectrum/32/142226_2.png) [@spectrum](https://meta.discourse.org/u/spectrum)\
**Post date:** [January 3, 2018, 8:05pm UTC](https://meta.discourse.org/t/duplicate-http-https-topics-are-randomly-created/77190/1 "2018-01-03T20:05:30Z")

</div>

Hi there,  
I recently transitioned my site from HTTP to HTTPS; all Discourse threads link to their original posts at [http://sitename.com/posts/](http://sitename.com/posts/)[post number], and with redirects in place it still works great for browsers.

However, we’re seeing some duplicate threads show up somewhat randomly, with original posts linking back to HTTPS links for posts on the homepage. As an example, for a thread created in ~2014 originating from [http://sitename.com/posts/243](http://sitename.com/posts/243), there’s now a new thread with no replies created, linking back to [https://sitename.com/posts/243](https://sitename.com/posts/243). I had written the discourseEmbedUrl as [http://sitename.com](http://sitename.com) to avoid the system mistakenly creating duplicate threads, but it still seems to do it randomly.

The code I’m using on the template page is here (with substitutions made):

```
      <script type="text/javascript">
        var discourseUrl = "https://discussion.sitename.com/",
            discourseEmbedUrl = "<?php print 'http://sitename.com/posts/'.$post->postId; ?>";

        (function() {
          var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
            d.src = discourseUrl + 'javascripts/embed.js';
          (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
        })();
      </script>

```

The variables discourseUrl and discourseEmbedUrl differ in HTTP/HTTPS approach because I did not want Discourse to view a post as “new” and re-create it, because of simply being accessed over HTTPS instead of over HTTP. Since browsers get redirected from HTTP to HTTPS, it’s worked thus far except for having random duplicates.

Has anyone else had this issue before? I had thought specifying [http://sitename.com](http://sitename.com) instead of [https://sitename.com](https://sitename.com) would be clear enough to avoid this issue so Discourse would see there is already a thread created for the post in question, but something seems to be going wrong still.

Is there a different approach I should take so that there aren’t random duplicate threads created?

---

_[View the full topic](https://meta.discourse.org/t/duplicate-http-https-topics-are-randomly-created/77190)._
