I have a nodejs application running on iis.
I have url rewrite rule which sends all request to a custom server.js page.
I want to add a new rule or modify the existing one so that a particular url /something reaches the iis and not the rule I have written.
My rule currently:
<rewrite>
<rules>
<rule name="node">
<match url="/*" />
<action type="Rewrite" url="server.js" />
</rule>
</rules>
</rewrite>
Please help on this one.
<rule name="sendToNode">
<match url="/*" />
<conditions>
<add input="{URL}" pattern="/something$" negate="true" />
</conditions>
<action type="Rewrite" url="server.js" />
</rule>
Related
I have this iis site for which I have added some rewrite rules.
The rewrite rule itself is simple If I access the site www.a.com rewrite/redirect to www.b.com
and redirect subpages to corresponding subpages on www.b.com
So have via IIS manager setup some rewrite rules.
<rewrite>
<rules>
<clear />
<rule name="Redirect to https" stopProcessing="true">
<match l=".*" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" l="https://{HTTP_HOST}{REQUEST_I}" redirectType="Permanent" appendQueryString="false" />
</rule>
<rule name="https://shop.a.com/5e/ -> https://www.b.com/products/5/" enabled="true" patternSyntax="ExactMatch" stopProcessing="true">
<match l="https://shop.a.com/5e/" />
<action type="Redirect" l="https://www.b.com/products/5/" logRewrittenl="false" />
</rule>
<rule name="https://shop.a.com/5e/ -> https://www.b.com/products/5/" enabled="true" patternSyntax="ExactMatch" stopProcessing="true">
<match l="https://shop.a.com/5e/" />
<action type="Redirect" l="https://www.b.com/products/5/" logRewrittenl="false" />
</rule>
<rule name="https://shop.a.com/10e/ -> https://www.b.com/products/10/" enabled="false" patternSyntax="ExactMatch" stopProcessing="true">
<match l="https://shop.a.com/10e/" />
<action type="Redirect" l="https://www.b.com/products/10/" logRewrittenl="true" />
</rule>
<rule name="https://shop.a.com/16e/ -> https://www.b.com/products/16/" enabled="false" patternSyntax="ExactMatch" stopProcessing="true">
<match l="https://shop.a.com/16e/" />
<action type="Redirect" l="https://www.b.com/products/16/" logRewrittenl="true" />
</rule>
<rule name="https://shop.a.com/3e/ -> https://www.b.com/products/3/" enabled="false" patternSyntax="ExactMatch" stopProcessing="true">
<match l="https://shop.a.com/3e/" />
<action type="Redirect" l="https://www.b.com/products/3/" logRewrittenl="true" />
</rule>
</rules>
</rewrite>
prior to this I had a rewrite that rewrote shop.a.com to www.b.com
This one should not be active anymore, but for somereason is this still active, and all the other rules listed here does not seem to work.
When I access shop.a.com/5e I enter www.b.com.
The network tab in chrome states that the url is being redirected to www.b.com, but have no idea where this redirect is listed if not in the web.config?
the url mentioned here are only examples and not the actual sites being managed.
Any idea on why this redirect is doing this?
I used regex match instead which made it work.
The exact matching via iis did not work as expected.
I want to write redirect rules in IIS 10. I googled it but could not found proper solution.
I have added some more scenarios.
https://testing.app.com/apptest should redirect to https://testing.app.com/apptest/account/login
https://testing.app.com/apptest/ should redirect to https://testing.app.com/apptest/account/login
https://test-apptest.testing.app.com/ should redirect to https://test-apptest.testing.app.com/account/login
https://test-apptest.testing.app.com should redirect to https://test-apptest.testing.app.com/account/login
Appreciated if someone can please help me with this.
What I tried so far is:
<rewrite>
<rules>
<rule name="Test1" stopProcessing="true">
<match url="apptest/login" />
<action type="None" />
</rule>
<rule name="login">
<match url="^apptest" />
<action type="Redirect" url="testing.app.com/apptest/login" appendQueryString="false" />
</rule>
</rules>
</rewrite>
You can try the rule below:
<rule name="test5" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="testing.app.com" />
<add input="{REQUEST_URI}" pattern="^/apptest$" />
</conditions>
<action type="Redirect" url="https://www.google.com/" appendQueryString="false" />
</rule>
I'm trying to make a rewrite map in IIS to rewrite any call from domain.com/v/{PATH} to domain.com/api/v/{PATH} as i've changed my hosting logic and as an external service can't change the .GET request is making to domain.com/v/{PATH} in domain.com/api/v/{PATH} i have to rewrite any call in IIS..
I've created the following rewriteMap:
<rewrite>
<rewriteMaps>
<rewriteMap name="vmenuAuth">
<add key="/v/" value="/api/v/" />
</rewriteMap>
</rewriteMaps>
<rules>
<rule name="Regola di reindirizzamento1 per vmenuAuth">
<match url=".*" />
<conditions>
<add input="{vmenuAuth:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
But it works only if the url has ONLY the /v/ so if i write domain.com/v/ it rewrite the url to domain.com/api/v/ but if i try to add the path domain.com/v/VHGbrbfFHHTRfbFKSZ it will still remain the same without redirecting the user to domain.com/api/v/VHGbrbfFHHTRfbFKSZ
It seems that it is unnecessary to apply the URL Rewrite Maps under the circumstance.
We will redirect the URL to the new path as long as we match the “/v/” segment, is it right?
Please refer to the below configuration.
<rewrite>
<rules>
<rule name="abc" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{Request_URI}" pattern="/v(.*)" />
</conditions>
<action type="Redirect" url="/api/v{C:1}" appendQueryString="false" />
</rule>
</rules>
<rewriteMaps>
<rewriteMap name="MyMap" defaultValue="">
<add key="1234" value="HtmlPage1.html"></add>
</rewriteMap>
</rewriteMaps>
</rewrite>
Feel free to let me know if there is anything I can help with.
I'm using IIS 10. I've a website that is reachable with subdomain1.domain.com and subdomain2.domain.com only on HTTPS protocol.
I would like to set up a rewrite rule only if request comes from subdomain2.domain.com where website should load the URL subdomain2.domain.com/la/signin. This last URL should be masked and not showed to the user.
I've tried a lot of rewrite rules and searched other suggestions on stackoverflow but every solutions did not worked for me, even without mask.
This one is just my last try without mask, but I've tried many other solutions:
<rewrite>
<rules>
<rule name="Redirect" stopProcessing="true">
<match url="https://subdomain2\.domain\.com$" />
<action type="Rewrite" url="{R:0}/la/signin" appendQueryString="true" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
Any other suggestion?
Please try this rule. It will rewrite https://subdomain2.domain.com(/) to subdomain2.domain.com/la/signin.
<rule name="Redirect" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="la/signin" appendQueryString="true" logRewrittenUrl="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="subdomain2\.domain\.com" />
<add input="{HTTPS}" pattern="^on$" />
<add input="{URL}" pattern="^(/)?$" />
</conditions>
</rule>
I have some old URLs in a forum application points to http://mydomain.tld/showthread.php?p=xxxx where xxxx is the an integer id.
My new forum application uses viewtopic.php?p=xxxx and I want to handle this using IIS web.config rewrite rules.
I have tried to add the last rule as the following:
<rewrite>
<rules>
<rule name="Redirect www to non www" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(.*)" />
<action type="Redirect" url="http://domain.tld/{R:1}" />
<conditions>
<add input="{HTTP_HOST}" pattern="^domain\.tld" negate="true" />
</conditions>
</rule>
<!-- this for change from showthread.php to viewtopic.php -->
<rule name="Rewrite" stopProcessing="true">
<match url="(.*)showthread\.php" />
<action type="Rewrite" url="viewtopic\.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
However, it does not able to redirect to the viewtopic.php. Any suggestion?
I have to enable httpRedirect in the IIS. Then I used this redirect rule in the web.config at the root of my forum:
<httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
<add wildcard="*showthread.php" destination="/viewtopic.php?$P" />
</httpRedirect>