You don't need any comparison syntax. The simplest syntax for these tests is:
RewriteCond %{HTTPS} on
Or:
RewriteCond %{HTTPS} off
If you wish to use the =
, you can, it just means it's a straight comparison instead of treating as a regex, as per:
=CondPattern Lexicographically equal. Treats the CondPattern as a plain string and compares it lexicographically to TestString. True if
TestString is lexicographically equal to CondPattern (the two strings
are exactly equal, character for character). If CondPattern is "" (two
quotation marks) this compares TestString to the empty string.
The comparison operators come in to their own for the various other tests that can be done with RewriteCond.
These options are needed because mod_rewrite is a powerful and flexible system. Having these options for comparison increases its utility and opens more possibilities than regexes alone. It also offers ways to improve legibility. For example =/specific/URL.html
is easier to read and replace later than ^/specific/URL\.html$
. If you check the info in the page I linked to, you will see that straight comparison is just one of many options, including file tests, less than/greater than, less than or equals, greater than or equals. All of which can run against captures from the rule (which is processed first), captures from the conditions, server variables, special variables (like HTTPS) and even custom mappings.
Having these options other than regexes opens up all kinds of possibilities that would not be there with regexes alone. Yes, the straight comparison can be viewed as unnecessary when regexes are available, but taking the larger context of the system it fits in too, it is well worth having included alongside less than, greater than etc. that regexes can't do and also makes the syntax for straight comparison simpler in some cases as mentioned above. The HTTPS example of yours just happens to be a very simple case, which taken in isolation can make the options appear unnecessary.