<rule name="WC2018" stopProcessing="true">
<match url="^product/sb/sales.htm" />
<action type="Rewrite" url="product/sb/market/sales.htm" />
</rule>
Above is the url rewrite that i do, the original link is
product/sb/sales.htm
I need to rewrite it to
product/sb/market/sales.htm
But it does not work. I not sure what went wrong.
You can try this rules :
<rule name="rule 1k" stopProcessing="true">
<match url="^product/sb/market/sales.htm$" ignoreCase="true" />
<action type="Rewrite" url="/product/sb/sales.htm" />
</rule>
Related
I'm tryin to force my website to only accept https, by adding the following to my webconfig:
<clear />
<rule name="Redirect to https" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>
This works, if you load the site using http it now re-directs the site to https, but every time I try to go to a different page or submit a form I get a:
405 - HTTP verb used to access this page is not allowed.
This currentle my webconfi:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="PW_BADPOST" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{REQUEST_METHOD}" matchType="Pattern" pattern="POST" ignoreCase="true" />
<add input="{HTTP_REFERER}" pattern=".*\/wp-admin.*" />
</conditions>
<action type="CustomResponse" statusCode="404"/>
</rule>
<rule name="PW_BadURL" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_URI}" pattern="\.php" />
<add input="{REQUEST_URI}" pattern="die\(" />
<add input="{REQUEST_URI}" pattern="connector\.asp" />
</conditions>
<action type="CustomResponse" statusCode="404"/>
</rule>
<!-- directories to ignore -->
<rule name="PW_IgnoreDir" stopProcessing="true">
<match url="^(css|img|images|js|tools)\/(.*)$" ignoreCase="true" />
<action type="None" />
</rule>
<!-- Pages -->
<rule name="PW_Pages" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="index.php?{R:1}" />
</rule>
</rules>
</rewrite>
<directoryBrowse enabled="false" />
</system.webServer>
</configuration>
I want to rewrite this URL
https://www.website.com/parameter-1?query=100345046
To this
https://www.website.com/parameter?query=100345046
Basically I want the -1 removed from the URL.
I made an example which works, using RegExr, but I don't know how to implement this using the IIS.
So far I made this rule but I can't get the query part after the -1 to stick the to rewrote URL.
<rule name="Redirect" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_URI}" pattern="^/parameter-1$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/parameter" appendQueryString="true" />
</rule>
Alright I figured it out.
<rule name="Redirect" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_URI}" pattern="/parameter-1\?query=(.*)$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/parameter?" appendQueryString="true" redirectType="Permanent" />
</rule>
I have a new site https://www.NewSite.com and I would like all the traffic to my old site https://www.OldSite.com to be redirected to the root of my new site https://www.NewSite.com/, with some exception.
For instance I would like the URL (among others) https://www.OldSite.com/noredirect not to be redirected and others to be rewritten. For instance:
https://www.OldSite.com -> https://www.NewSite.com/
https://www.OldSite.com/library->https://www.NewSite.com/
https://www.OldSite.com/kb/ -> https://www.newsite.com/kb
https://www.OldSite.com/kb/articles.aspx?id=45 -> https://www.NewSite.com/kb
https://www.OldSite.com/noredirect -> https://www.oldsite.com/noredirect
https://www.OldSite.com/noredirect/page.aspx -> https://www.oldsite.com/noredirect/page.aspx
Therefore I wrote two rules in my Old Site site in IIS:
<rewrite>
<rules>
<clear />
<rule name="Rewrite To New Site" stopProcessing="true">
<match url="/kb(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="https://www.newsite.com/kb" />
</rule>
<rule name="Redirect to New Site" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_URI}" pattern="(.*)/noredirect$" negate="true" />
</conditions>
<action type="Redirect" url="https://www.newsite.com" appendQueryString="false" />
</rule>
</rules>
</rewrite>
This rules just redirect all the requests to my old site to the root of my new site, ignoring the exceptions and the rewrite rule. The same happens with:
<rule name="Redirect to New Site" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_URI}" pattern="^/noredirect(.*)" negate="true" />
</conditions>
<action type="Redirect" url="https://www.newsite.com" appendQueryString="false" />
</rule>
What am I doing wrong?
Make sure you've checked "Enable proxy" under Application Request Routing cache.
You can find some information about it here:
http://www.iis.net/learn/extensions/configuring-application-request-routing-%28arr%29/creating-a-forward-proxy-using-application-request-routing
Good luck!
How to add multiple URL rewrite rules in a web.config
I want to match any url that contains "sales" and "registrationsuccess".
I get errors with when I try the following:
<rewrite>
<rules>
<rule name="Redirect HTTP to HTTPS" stopProcessing="true">
<match url="(.*sales*)"/>
<match url="(.*registrationsuccess*)"/>
<conditions>
<add input="{HTTPS}" pattern="^OFF$"/>
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther"/>
</rule>
</rules>
</rewrite>
This is how you add more than one rule:
<rewrite>
<rules>
<rule name="Redirect HTTP to HTTPS (Sales)" stopProcessing="true">
<match url="(.*sales*)"/>
<conditions>
<add input="{HTTPS}" pattern="^OFF$"/>
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther"/>
</rule>
<rule name="Redirect HTTP to HTTPS (RegistrationSucces)" stopProcessing="true">
<match url="(.*registrationsuccess*)"/>
<conditions>
<add input="{HTTPS}" pattern="^OFF$"/>
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther"/>
</rule>
</rules>
</rewrite>
But for what you're trying to do, you can do it with one rule, like below:
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="ON" />
<add input="{PATH_INFO}" pattern="^(.*)/sales/(.*)" />
<add input="{PATH_INFO}" pattern="^(.*)/registrationsuccess/(.*)" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
I am trying to rewrite a html response with an outboundrule, but it is not working: This are my inbound and outbound rules:
<rules>
<rule name="IE56 Do not gzip js and css" stopProcessing="false">
<match url="\.(css|js|emz|jpg|htm|html)" />
<action type="None" />
<serverVariables>
<set name="HTTP_ACCEPT_ENCODING" value="" />
</serverVariables>
</rule>
<rule name="Route the requests for eserver" patternSyntax="ECMAScript">
<match url="^eServer/(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{CACHE_URL}" pattern="^(https?)://" />
</conditions>
<action type="Rewrite" url="{C:1}://mckyesvr/eServer/{R:1}" />
<serverVariables>
<set name="HTTP_ACCEPT_ENCODING" value="" />
</serverVariables>
</rule>
<outboundRules>
<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
<match filterByTags="A, Area, Base, Form, Frame, Head, IFrame,Img, Input, Link, Script" pattern="^http(s)?://mckyesvr/eServer/(.*)" ignoreCase="true" />
<conditions>
<add input="{URL}" pattern="/PageLoader" negate="true" />
</conditions>
<action type="Rewrite" value="/eServer/{R:2}" />
</rule>
<rule name="ReverseProxyOutboundRule8" preCondition="ResponseIsHtml1">
<match pattern="http://mckyesvr/eServer/PageLoader.asp?Page=Process_Safety.dsp"/>
<action type="Rewrite" value="/eServer/PageLoader.asp?Page=Process_Safety.dsp" />
</rule>
They work perfectly with almost every HTML response except with the ones that have this HTML reponses form:
"<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
.......etc and this is the part that I want to rewrite:
<_a href="http://mckyesvr/eServer/PageLoader.asp?Page=Process_Safety.dsp"
target="_parent">Go Back to Process Safety------
I have tried changing the compressing, change the outbound rules, move a thousand parameters but nothing has worked out until now, I don't know why this is happening just with an HTML response as the one indicated above, it looks like it is coded because Outboundrules don't catch it.