I need a temporary fix by adding a 0 in the URL between 2 slashes '//' until a permanent fix is done.
Here is a sample URL and below is the rewrite rule that I did but it doesn't work.
https://example.com/PortalWebService/api/List/getpdf/10/1//16/en-ca/
<rewrite>
<rules>
<rule name="Rewrite URL add 0 between //" patternSyntax="Wildcard" stopProcessing="false">
<match url="*1//*" />
<action type="Rewrite" url="{R:1}1/0/{R:2}" appendQueryString="true" logRewrittenUrl="false" />
</rule>
</rules>
</rewrite>
Can anyone help me?
Thanks
Try a small tweak to your match url - turn those asterisks into match groups so that URL Rewrite knows how to capture and replace their contents:
<match url="^https://(.*)1//(.*)" />
In my opinion your original rule is correct.
You could try to put the complete url in this way:
<action type="Rewrite" url="https://{R:1}1/0/{R:2}"
Only for a try: If you use the action type "Redirect" is it working?
Related
How can convert url www.mydomain.com/home to www.mydomain.com/api/v1/home
if the requested api link don't contain api/v1
I need someone help to write iis rewrite rule in web.config to fit this case
best regards
if the requested api link don't contain api/v1
You can use the parameter ^home$ to make the requested url match only home, this way api/v1 is not contained.
<rewrite>
<rules>
<rule name="Test" stopProcessing="true">
<match url="^home$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.domainname.com$" />
</conditions>
<action type="Redirect" url="http://www.domainname.com/api/v1/home" appendQueryString="false" />
</rule>
</rules>
</rewrite>
Body cannot contain mydomain, so i use domainname instead of it.
I've got some IIS rewrite rules in place, and everything is working fine. But i feel like i can consolidate them.
Here are my rules:
<rule name="Blog - Advice - root" patternSyntax="ExactMatch" stopProcessing="true">
<match url="advice" />
<action type="Rewrite" url="https://mysite.wpengine.com/advice" />
</rule>
<rule name="Blog - Advice - root (with slash)" patternSyntax="ExactMatch" stopProcessing="true">
<match url="advice/" />
<action type="Rewrite" url="https://mysite.wpengine.com/advice" />
</rule>
<rule name="Blog - Advice" stopProcessing="true">
<match url="^advice/?(.*)" />
<action type="Rewrite" url="https://mysite.wpengine.com/advice/{R:1}" />
</rule>
I want to match the following examples:
/advice
/advice/ (should rewrite without the slash)
/advice/sdfsdf
/advice/sdfsdf/ (should rewrite without the slash)
/advice/sdfdsf/sdfds
Can it be done with 1 (or 2) routes?
If i leave the second one out for example, Wordpress (the site i'm rewriting to), will do a 301 redirect to a URL without the slash, and i lose the rewrite since the URL is changed again. (so i end up at mysite.wpengine.com/advice, which is wrong).
So i need to make sure any rewrites don't involve a redirect on the target site end.
Many thanks :)
Is it possible to remove a directory from a URL without using a redirect action? In other words can I do it with only a "rewrite" action.
I need to take a URL like this: http://www.example.com/de/folderabc/specs/default.aspx and remove the "folderabc" directory to make it like this: http://www.example.com/de/specs/default.aspx
So far any variation I have tried like this is not working:
<system.webServer>
<rewrite>
<rules>
<rule name="removefolder" stopProcessing="true">
<match url="folderabc/(.*)" />
<action type="Rewrite" url="/{R:0}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
I am using IIS 7.5.
Try putting a caret ^ in your url to match on.
<match url="^folderabc/(.*)" />
I'm not familiarized with this feature and I've found some examples how to do something but I don't know how to set this case:
I want this url http://www.domain.co.uk/anything/en to become http://www.domain.co.uk/anything/
I want to remove the final 'en'
I've tried with:
^/([_0-9a-z-]+)/([_0-9a-z-]+)/en
/{R:1}/{R:2}
or
^http://www.domain.co.uk/([_0-9a-z-]+)/(en)
http://www.domain.co.uk/{R:1}/
But it doesn't work.
You can use the following rule:
<rule name="Remove en" stopProcessing="true">
<match url="^(.*)/en$" />
<action type="Rewrite" url="{R:1}" />
</rule>
It will match any url ending with /en and remove this part.
From your example, http://www.domain.co.uk/anything/en will be rewritten as http://www.domain.co.uk/anything
If you want the user to be redirected, then use the following rule:
<rule name="Remove en" stopProcessing="true">
<match url="^(.*)/en$" />
<action type="Redirect" url="{R:1}" />
</rule>
The type="Redirect" with no option triggers a permanent(301) redirect.
Hey there my redicret is not working and i don't understand why.
My rule looks like this :
<rewrite>
<rules>
<rule name="rewrite to article" stopProcessing="false">
<match url="^showfirm.asp\?rubrik=([_0-9a-z-]+)" />
<action type="Redirect" url="esbjerg/sog/?q={R:1}&t=" redirectType="Temporary" />
</rule>
</rules>
</rewrite>
When i try to match the url with
http://localhost/showfirm.asp?rubrik=sometexthere
I hit my custom 404 page, instead of hitting
http://localhost/esbjerg/sog/?q=sometexthere&t=
Anyone who can help ? Im using an IIS 7.5 with urlrewriter 2.0
Ps : First time doing an url redirect :)
Try this:
<match url="^showfirm\.asp\?rubrik=([_0-9a-z-]+)" />