I have a url http://example.com/abc/pqr/112-digital I want do 301 redirect to http://example.com/abc/pqr/digital
not working..
<rule name="RedirectToBlog140" stopProcessing="true">
<match url="^abc/pqr/112-digital?$|^abc/pqr/112-digital(.*)$" />
<conditions />
<serverVariables />
<action type="Redirect" url="abc/pqr/digital/{R:1}" />
</rule>
Please Help
Related
I want to rewrite an existing url /rss/content.aspx?id=4878 to display as /rss.
I also need requests to /rss to display this same content. I have this rule:
<rule name="ContentRSS">
<match url="^rss$" />
<action type="Rewrite" url="rss/content.aspx?id=4878" />
</rule>
but it doesn't rewrite requests to rss/content.aspx?id=4878 as /rss
You rule should be:
<rules>
<rule name="ContentRSS redirect" stopProcessing="true">
<match url="^rss/content.aspx$" />
<action type="Redirect" url="/rss" appendQueryString="false" />
<conditions>
<add input="{QUERY_STRING}" pattern="id=4878" />
</conditions>
</rule>
<rule name="ContentRSS rrewrite">
<match url="^rss$" />
<action type="Rewrite" url="/rss/content.aspx?id=4878" />
</rule>
</rules>
This rule will rewrite /rss to /rss/content.aspx?id=4878. And when you will try to open in browser rss/content.aspx?id=4878 it will redirect to /rss
I have a working rule that removes www. for all urls coming in. I have a webserivce that the redirect will change from a POST to a GET. I need to exclude the URL https://www.foo.net/WebServices/service.asmx from this rule.
I have looked at other solutions on SO with no success.
<rewrite>
<rules>
<rule name="Remove WWW" enabled="true" stopProcessing="true">
<match url=".*"/>
<conditions>
<add input="{HTTP_HOST}" pattern="^(www\.)(foo\.net)" />
</conditions>
<action type="Redirect" url="https://{C:2}/{R:1}" />
</rule>
</rules>
</rewrite>
You can do that easily by adding a condition to "not match" (aka adding "negate='true'" ), something like this should work:
<rules>
<rule name="Remove WWW" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.foo\.net$" />
<add input="{URL}" pattern="^/WebServices/service\.asmx$" negate="true" />
</conditions>
<action type="Redirect" url="https://foo.net/{R:1}" />
</rule>
</rules>
This is how i currently want to redirect my site to
when i try navigating to
http://sub1.sitename.com it should redirect to sitename.com/newprojects/sub1
and the same for sub2
i tried using it like this but it ends up loading www.sitename.com
<rewrite>
<rules>
<rule name="Redirect" stopProcessing="true">
<match url="^sub1\.sitename\.com$" ignoreCase="true" />
<action type="Redirect" url="sitename\.com/newprojects/sub1/" redirectType="Permanent" />
</rule>
<rule name="Redirect1" stopProcessing="true">
<match url="^sub2\.sitename\.com$" ignoreCase="true" />
<action type="Redirect" url="sitename\.com/newprojects/sub2/" redirectType="Permanent" /> </rule>
</rules>
</rewrite>
You could try matching all the URL's and then filtering based on what you want to redirect.
<rewrite>
<rules>
<rule name="sub1 redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^sub1\.site\.com(/)?$"/>
<add input="{PATH_INFO}" pattern="^/newprojects/sub1/" negate="true" />
</conditions>
<action type="Rewrite" url="\newprojects\sub1\{R:0}" />
</rule>
</rules>
</rewrite>
this worked for me.
Rule is
<rule name="Redirect to new host" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{REQUEST_URI}" pattern=".*mycompany\.com/blogs(.*)" />
</conditions>
<action type="Redirect" url="http://blogs.mycompany.com{C:1}" />
</rule>
The module's built-in pattern tester says that http://subdomain.mycompany.com/blogs/blog1 matches, so it should redirect to http://blogs.mycompany.com/blog1, but nothing happens. Would greatly appreciate help fixing this rule or writing one that does work!
It's work:
<rule name="Test" stopProcessing="true">
<match url=".*" />
<conditions trackAllCaptures="true">
<add input="{HTTP_HOST}" pattern="^.*mycompany\.com$" />
<add input="{URL}" pattern="^/blogs(.*)$" />
</conditions>
<action type="Redirect" url="http://blogs.mycompany.com{C:1}" />
</rule>
I'm using the url rewrite features in web.config to redirect my subdomains. Here is my rule :
<rule name="redirect_page">
<match url=".*" ignoreCase="false" negate="false" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\." negate="true" />
<add input="{HTTP_HOST}" pattern="^([\w\-]+)\.mySite\.com$" />
</conditions>
<action type="Rewrite" url="profile.aspx?name={C:1}" />
</rule>
This works great :
http://myUser.mySite.com redirect to http://myUser.mySite.com/profile.aspx?name=myUser
BUT
http://myUser.mySite.com/image/myImage.jpg redirect to http://myUser.mySite.com/profile.aspx?name=myUser
=> What I want :
http://myUser.mySite.com/image/myImage.jpg redirect to http://myUser.mySite.com/image/myImage.jpg
Any idea ?
Well this is a little tricky but here is the solution :
<rule name="SubDomainDoNothing" stopProcessing="true">
<match url="(.+)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(?!www)(\w+)\.plugandtable\.com$" />
</conditions>
<action type="Rewrite" url="{R:1}" />
</rule>
<rule name="SubDomainRedirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(?!www)(\w+)\.plugandtable\.com$" />
</conditions>
<action type="Rewrite" url="profile.aspx?name={C:1}" />
</rule>