Samul
Samul

Reputation: 2019

What does this symbol make inside htaccess

frequently I use this:

<If "%{QUERY_STRING} =~ m#^.*TTT.*$#i">

I would like to know what is =~? I suppose it's related to "equal". So how do I make "different"?

Upvotes: 3

Views: 525

Answers (1)

anubhava
anubhava

Reputation: 785196

=~ is used for regular expression based evaluation in expressions. Here is official Apache documentation for expressions.

To negate use !~ like this:

<If "%{QUERY_STRING} !~ /foobar/">
   Redirect 301 "/" "http://www.example.com/"
</If> 

Check Binary Operators List

Comparison operators

Name    Description
==      String equality
!=      String inequality
<       String less than
<=      String less than or equal
>       String greater than
>=      String greater than or equal
=~       String matches the regular expression
!~       String does not match the regular expression
-eq eq  Integer equality
-ne ne  Integer inequality
-lt lt  Integer less than
-le le  Integer less than or equal
-gt gt  Integer greater than
-ge ge  Integer greater than or equal

Upvotes: 4

Related Questions