I've seen several blogs and questions which I believe match what I'm doing, but it's not working. URL Rewrite module is installed. I'm resetting IIS after I save this web.config file. I've tried using IIS's GUI as well with same results. Is there something else I'm not aware of?
<rewrite>
<rules>
<rule name="Redirect domain.com to www" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^domain.us$" />
</conditions>
<action type="Redirect" url="http://www.domain.us/{R:0}" />
</rule>
</rules>
</rewrite>
Ok, I forgot to add the binding domain.us to the site. Woops!
Related
I want to redirect a particular url to another server. Following is my rewrite rule:
<rewrite>
<rules>
<rule name="mydomain" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(http|https)(://domain1\.)(example\.)(com|net)(/research)(.*)" />
<action type="Redirect" url="{R1}://{R3}{R4}/domain1research" />
</rule>
</rules>
</rewrite>
I am expecting that if a user types https://domain1.example.com/research, they should be redirected to https://example.com/domain1research. I've tested the expression with multiple variations on the url (.com, .net and query string) and it matches always. But when I run the website it never gets re-directed to the other page. I've URL rewrites in many web apps and they all work fine. I am not able to put my fingre on what I'm missing here.
I have tried it locally with an entry in hosts file and in a published website (Asp.Net MVC) on Azure but nothing works.
As per #lex Li's blog post and Microsoft documents, following rewrite works:
<rewrite>
<rules>
<rule name="mydomain" patternSyntax="ECMAScript" stopProcessing="true">
<match url="research" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{HTTP_HOST}" pattern="(domain1\.)(example\.(com|net)" />
</conditions>
<action type="Redirect" url="https://{C:2}/domain1research" />
</rule>
</rules>
</rewrite>
I need to redirect from
http://someserver/someapplication.page.aspx
to
http://someserver.domain.com/someapplication.page.aspx
Both the requests lead to the same server.
someserver/ works through our company's internal DNS
This is the same question as Redirecting to Full Domain
but I want an IIS solution for this, not code. My guess is it will have something to do with adding a httpRedirect add element in Configuration Editor using wildcards.
You can use URL Rewrite for that which is the recommended way to do it in IIS, simply add a web.config with a rule like:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to full domain" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^someserver$" />
</conditions>
<action type="Redirect" url="http://someserver.domain.com/{R:0}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I'm trying to set the canonical URL for my site (macton.com) to add the www in the beginning. The site is hosted using IIS and I installed the URL Rewriter Extension.
Here is the code I put in the web.config file. However, it doesn't seem to do anything, because it remains macton.com.
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite to www" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^macton\.com$" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="http://www.macton.com/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
After this I have a bunch of <location> tags with redirects that work fine. I tried using a redirect from macton.com → www.macton.com but that just creates an infinite redirect loop (DUH!)
Any idea why this wouldn't be working? Everywhere I look says this is the correct code!
This link can help:
http://www.awseibert.net/how-to/redirecting-canonical-names-in-iis-7
Have you also added macton.com to the binding of your website?
I use IIS 7.5
I have a website wich has a valid host like:
A) mysite.co.uk
and a DEFAULT host (using for testing proposes provided by the hosting company):
B) mysite.hosting.com
Website is visible on both address, creating a DUPLICATE CONTENT issue for Search Engine.
I need redirect all the traffic (for all pages) from B to A using a 301 redirect.
IIS7.5 Http Redirect it is not design for this situation so I suppose to use IIS 7.5 Url Rewrite Module.
My questions: how write the ROLE in my web.config? Thanks
Try adding something like this between the <System.webServer> tags in your web.config:
<rewrite>
<rules>
<rule name="Redirect mysite.hosting.com to mysite.co.uk" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="mysite.hosting.com" />
</conditions>
<action type="Redirect" url="http://mysite.co.uk/{R:0}" />
</rule>
</rules>
</rewrite>
Alternatively, you can do this using global rules by adding:
<rewrite>
<globalRules>
<rule name="Redirects to mysite.co.uk" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="mysite.hosting.com$" />
</conditions>
<action type="Redirect" url="http://mysite.co.uk/{R:0}" />
</rule>
</globalRules>
</rewrite>
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>