array=("word" "two words") # let's look for "two words"
grep
и printf
: (printf '%s\n' "${array[@]}" | grep -x -q "two words") && <run_your_if_found_command_here>
for
: (for e in "${array[@]}"; do [[ "$e" == "two words" ]] && exit 0; done; exit 1) && <run_your_if_found_command_here>
Для not_found результатов добавьте || <run_your_if_notfound_command_here>
Мне удалось это, добавив два правила перезаписи URL в файл Web.config
:
<rule name="Redirect top domains with non-www to www" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern=".*localhost.*" negate="true" />
<add input="{HTTP_HOST}" pattern=".*stage\..*" negate="true" />
<add input="{HTTP_HOST}" pattern=".*dev\..*" negate="true" />
<add input="{HTTP_HOST}" pattern="^([^\.]+)\.([^\.]+)$" />
</conditions>
<action type="Redirect" url="https://www.{HTTP_HOST}/{R:1}" redirectType="Permanent" />
<serverVariables>
<set name="Redirect" value="false" />
</serverVariables>
</rule>
<rule name="Force HTTPS" enabled="true" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern=".*localhost.*" negate="true" />
<add input="{HTTP_HOST}" pattern=".*stage\..*" negate="true" />
<add input="{HTTP_HOST}" pattern=".*dev\..*" negate="true" />
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
Для исключения используются все условия с negate="true"
. Следовательно, все URL-адреса, содержащие «localhost», «stage» и «dev», исключаются из перезаписи URL. Вы можете удалить эти условия, если это не требуется.
Подробнее об атрибуте negate в http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite- модуль
http://example.com
, он перенаправляется наhttps://example.com
... знаете ли вы, почему он не перенаправляется наhttps://www.example.com
? – Flo 28 November 2017 в 17:19