# Outgoing partial links -\> https (on the fly)? - NOT http

**URL:** <https://meta.discourse.org/t/outgoing-partial-links-https-on-the-fly-not-http/291374>\
**Category:** Self-hosting\
**Created:** [January 12, 2024, 12:27am UTC](https://meta.discourse.org/t/outgoing-partial-links-https-on-the-fly-not-http/291374 "2024-01-12T00:27:58Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![mitchd](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mitchd/32/270120_2.png) [@mitchd](https://meta.discourse.org/u/mitchd)\
**Post date:** [January 15, 2024, 12:32am UTC](https://meta.discourse.org/t/outgoing-partial-links-https-on-the-fly-not-http/291374/7 "2024-01-15T00:32:25Z")

</div>

Checking if http (and https with a similar function) is possible, using just the head of the target page, code copied from:

> <https://stackoverflow.com/questions/65955022/python-check-if-webpage-is-http-or-https>

```plaintext
def check_http_url(url):
    HTTP_URL = f'http://{url}'
    try:
        HTTP_URL = urlparse(HTTP_URL)
        connection = HTTPConnection(HTTP_URL.netloc)
        connection.request('HEAD', HTTP_URL.path)
        if connection.getresponse():
            return True
        else:
            return False
    except:
        return False

```

So with that (translated to Ruby if I recall), Discourse back-end could find out if the target of a partial link given in a post is https or http, then (with a preference for https) open the correct target link for the user?

---

_[View the full topic](https://meta.discourse.org/t/outgoing-partial-links-https-on-the-fly-not-http/291374)._
