URL Scheme Rewriting, from HTTP to HTTPS, for Specific domains, within a Browser

216 Views Asked by At

Is there a way to configure browser (Firefox/Chrome) such that, if it encounters an HTTP URL (clicked or entered on address bar - eg: http://abc.xyz.com/... ), it modifies it to an https URL https://abc.xyz.com/...

Note that the site abc.xyz.com accepts both http:// and https:// schemes for the same URL. This site does not do any redirection for http:// links to enforce https scheme, and I do not want to access this site via http:// scheme.

I understand that this can be done with help of a web-server proxy (eg: Apache's mod_rewrite), but I am looking for a browser-only solution (say, via browser's "about:config" variables or some browser plugin, or some other method).

Adding abc.xyz.com to the browser's HSTS preloaded list seems like the best way to do this, but that can only by initiated and setup by abc.xyz.com site's admin. "HTTPS Everywhere" browser plugin comes close, but I could not find how to add my own/preferred sites in it's UI.

1

There are 1 best solutions below

0
Sathya Meda On

Found a way to do it, with "HTTPS Everywhere" Firefox plugin.

However note that "HTTPS Everywhere" has its own rulesets for numerous/popular sites (maintained elsewhere). This is only needed for custom sites, not yet supported by "HTTPS Everywhere".

Create a ruleset in a file such as below in Firefox profile directory as below (Windows 10) and restart the browser.

<!--
THIS_FILE:  FIREFOX_PROFILE_DIRECTORY\HTTPSEverywhereUserRules\my_torrents.xml
FIREFOX_PROFILE_DIRECTORY:  %APPDATA%\Mozilla\Firefox\Profiles\...
NOTE: To avoid un-necessary entries, check if custom hosts/sites are already supported in https://www.eff.org/https-everywhere/atlas/ , before adding it here
-->

<ruleset name="MY_HTTPS_RULESET">
  
<!-- for my Wiki server, always use HTTPS -->
<target host="192.168.1.210" />

<!-- for a site not yet supported by HTTPS Everywhere, but want this in HTTPS -->
<target host="torrasave.download" />

<!-- add more such custom entries -->
<!-- add more such custom entries -->

<rule from="^http:" to="https:" />
</ruleset>