Here is my web.config rule
<rule name="spiderRedirect" stopProcessing="true">
<match url=".post/([0-9a-zA-Z]+)/([0-9a-zA-Z]+)/([0-9a-zA-Z-]+)" />
<action type="Redirect" url="https://example.net/bot/post.php?category={toLower:{R:1}}&id={toLower:{R:2}}&title={toLower:{R:3}}" appendQueryString="false" />
</rule>
This should give this result
input:
https://example.net/post/celebrity/4cHYQ7i/maisie-williams
should result in:
{R1}: celebrity
{R2}: 4cHYQ7i
{R3}: maisie-williams
and it should redirect to:
https://example.net/bot/post.php?category=celebrity&id=4cHYQ7i&title=maisie-williams
This input:
https://example.net/post/nerdy/NE5cHQZ/when-i-have-to-do-technical-support
should result in:
{R1}: nerdy
{R2}: NE5cHQZ
{R3}: when-i-have-to-do-technical-support
The server runs and I am quite sure the regex is correct, but the rule is never triggered. I am never redirected to google, even if I use the above input.
Why isn't the rule triggered?
I got it working. Also with check for User agent. I use this to redirect web crawlers.
<rule name="spiderRedirect" stopProcessing="true">
<match url=".?post/([0-9a-zA-Z]+)/([0-9a-zA-Z]+)/([0-9a-zA-Z-]+)" />
<conditions>
<add input="{HTTP_USER_AGENT}" pattern="(Google|MSNBot|Twitterbot|Pinterest|Facebot|facebookexternalhit|MJ12bot|bingbot|SimplePie|SiteLockSpider|okhttp|curl|YandexBot|ScoutJet|Slurp|DuckDuckBot|Baiduspider|Sogou|Konqueror|Exabot|ia_archiver|Screaming)"/>
<add input="{HTTPS}" pattern="on"/>
</conditions>
<action type="Redirect" url="https://example.net/bot/post.php?category={toLower:{R:1}}&id={toLower:{R:2}}&title={toLower:{R:3}}" appendQueryString="false" />
</rule>
You will escape "/" to matching your different input. The new regex is :
([0-9a-zA-Z]+)\/([0-9a-zA-Z]+)\/([0-9a-zA-Z-]+)
You can test it on https://regex101.com . It match for your two different input.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.