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.
Related
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>
I dont understand writing URL Rewrite aspects yet. But need assistance as I dont know what I am doing incorrectly.
My goal is when a USER clicks on a link
www.example.com/NM/Registration?ctl=PasswordReset&resetToken=db08aa18-0810-417d-a633-131635bf9e8e
I would like the user to be redirected to
www.example.com/Registration?ctl=PasswordReset&resetToken=db08aa18-0810-417d-a633-131635bf9e8e
As you can see I would like to redirect without the NM in the URL path to the root domain.
I have this in my web.config file but it seems that it wont redirect properly:
<rewrite>
<rules>
<rule name="Query String Rewrite">
<match url="/NM/Registration" />
<conditions>
<add input="{QUERY_STRING}" pattern="ctl=([a-z]+)" />
<add input="##{C:1}##_{QUERY_STRING}" pattern="##([^#]+)##_.*resetToken=([_0-9a-z-]+)" />
</conditions>
<action type="Redirect" url="http://www.example.com/Registration?ctl={C:1}&resetToken={C:2}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
I figured out my answer. I ended up rewriting the rule so hopefully this will help out anyone in the future.
<rewrite>
<rules>
<rule name="Query String For Redirect">
<match url="NM/Registration" />
<conditions>
<add input="{QUERY_STRING}" pattern="ctl=([a-z]+)&resetToken=([_0-9a-z-]+)" />
</conditions>
<action type="Redirect" url="Registration?ctl={C:1}&resetToken={C:2}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
i have two domains which share a similar link for a content that is /games-for-cats. What i want is redirecting the games-for-cats link to another link for FR website for instance but leaving the games-for-cats link untouched for other domain. I am using IIS and asp.net MVC so i tried doing this in the Web.Config but this isn't working. Below is what i tried to do.
<rules>
<rule name="Redirect rule pl for Redirects">
<match url=".*" />
<conditions>
<add input="{Redirects:{REQUEST_URI}}" pattern="(^(preprod\.test-website\.pl)(.*)$)" />
</conditions>
<action type="Redirect" url="{C:3}" appendQueryString="false" redirectType="Permanent" />
</rule>
</rules>
<rewriteMaps>
<rewriteMap name="Redirects">
<add key="/games-for-cats" value="/link-to-be-redirected" />
</rewriteMap>
</rewriteMaps>
Can someone guide to what the correct rewrite rule is.
Thanks.
You need to add an additional condition to your rule which will trigger your rule for a specific domain only:
<rule name="Redirect rule pl for Redirects">
<match url=".*" />
<conditions>
<add input="{Redirects:{REQUEST_URI}}" pattern="(.+)" />
<add input="{HTTP_HOST}" pattern="^preprod\.test-website\.pl$" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" redirectType="Permanent" />
</rule>
I have Asp.NET Application installed on 'default web site\orchard'... accessible at http://localhost/orchard, and I want to use URL Rewrite. I added rules:
<rewrite>
<rewriteMaps>
<rewriteMap name="Blogger">
<add key="/aaa" value="/tags/tag1" />
</rewriteMap>
</rewriteMaps>
<rules>
<clear />
<rule name="Rewrite rule1 for Blogger" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{Blogger:{REQUEST_URI}}" pattern="(.*)" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
But when I go to http://localhost/orchard/aaa then error 404 is returned instead of redirecting to http://localhost/orchard/tags/tag1.
When I put my web application in the root folder of website redirection works. http://localhost/aaa is redirected to http://localhost/tags/tag1.
What I'm doing wrong?
Thanks for help.
I want add a rewrite rule to IIS 7 rewrite.
I want to redirect a user from page
http://localhost/myapp/register.html to http://localhost/myapp/register/register.html
And similar for other pages.
Any help?
Can I do the same using a rewrite action?
Using IIS7 and Windows Server 2008.
Thanks.
I'm not sure if it suits your needs but you can try this one (and maybe make some small adjustments if the case):
<system.webServer>
<rewrite>
<rewriteMaps>
<rewriteMap name="Register Redirect">
<add key="register.html" value="/register/register.html" />
</rewriteMap>
</rewriteMaps>
<rules>
<rule name="Redirect rule1 for Register Redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{URL}" pattern="^(.*)/register/(.*)(\.html)?$" negate="true" />
</conditions>
<action type="Redirect" url="{HOST}/register/{R:1}" appendQueryString="true" redirectType="Found" />
</rule>
</rules>
</rewrite>
</system.webServer>