I need redirect only main domain with web config redirect rules, and redirect an specific subdomain, but not redirect any other subdomain:
What I need:
if www.maindomain.com -> redirect to www.maindomain.com/index.html
if www.maindomain.com/specificSubdomain -> redirect to www.maindomain.com/specificSubdomain/index.html
if www.maindomain.com/whateverOther -> not redirect, goes to www.maindomain.com/whateverOther
Actually I have this code, but It not works appropiately:
<rule name="redi" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="www.maindomain\.com/index.html$" negate="true" />
<add input="{HTTP_HOST}" pattern="www.maindomain\.com/specificSubdomain/$" negate="true" />
<add input="{HTTP_HOST}" pattern="www.maindomain\.com" negate="false" />
<add input="{HTTP_HOST}" pattern="www\.maindomain\.com/$" negate="true" />
</conditions>
<action type="Redirect" url="https://www.maindomain.com/index.html" redirectType="Found"/>
</rule>
I have probed different combinations but any works, ideas? Thanks!
Related
I have this section in my web config to redirect http requests to https excluding .asmx references
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{URL}" pattern="^.aspx" ignoreCase="true" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
This redirects http requests OK but web services don't work - I get
<head><title>Document Moved</title></head>
<body><h1>Object Moved</h1>This document may be found here</body>
with the error genereated at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at PCS_Spe
cification.wsEntrant.WSEntrant.refresh
<add input="{URL}" pattern="^.aspx" ignoreCase="true" negate="true" />
You want to stop redirect of .asmx, but in your rewrite rule, your parameter is .aspx, so you need to change the parameter to .asmx.
Or you can also try the following rewrite rules:
<rule name="RewriteAllButasmx" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{URL}" negate="true" pattern="\.asmx$" />
</conditions>
<action type="Rewrite" url="https://{HTTP_HOST}/{R:1}" />
I submit number domain for my site. I need to redirect all domain such as www.siteName.net , www.siteName.ir , www.siteName.co to www.siteName.com via IIS.
Is this Possible?
If not Possible what is current solution?
It is possible with this rule:
<rule name="all domains www.siteName* to www.siteName.com" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^www.siteName" ignoreCase="true" />
<add input="{HTTP_HOST}" pattern="^www.siteName.com" negate="true" ignoreCase="true" />
</conditions>
<action type="Redirect" url="http://www.siteName.com/{R:1}" />
</rule>
It will redirect everything for domains www.siteName* to www.siteName.com
I have a situation where our client runs their Umbraco based website with load balancing, and we have the following rule that redirects request to all of these servers to the primary domain "https://www.ourclient.co.uk".
This is the code for that redirect:
<!-- Canonicalize all domains to a single domain -->
<rule name="SEO - http canonical redirect" stopProcessing="true" enabled="false">
<match url="(.*)"/>
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^www\.ourclient\.co\.uk" negate="true"/>
<add input="{HTTP_HOST}" pattern="^admin\.ourclient\.co\.uk" negate="true"/>
<add input="{HTTP_HOST}" pattern="^01-live\.ourclient\.co\.uk" negate="true"/>
<add input="{HTTP_HOST}" pattern="^02-live\.ourclient\.co\.uk" negate="true"/>
<add input="{HTTP_HOST}" pattern="^03-live\.ourclient\.co\.uk" negate="true"/>
<add input="{HTTP_HOST}" pattern="^04-live\.ourclient\.co\.uk" negate="true"/>
</conditions>
<action type="Redirect" url="https://www.ourclient.co.uk/{R:1}"/>
</rule>
Now what I need to achieve is any request to https://www.ourclient.co.uk/umbraco/ is redirected to https://admin.ourclient.co.uk/umbraco/ but for the life of me I just can't get anything to work.
Any help towards a solution will be very welcome, as would any corrections to my post.
Just add a new rule.
<rules>
<rule name="SEO - http canonical redirect">
... your old stuff ... but exclude the admin.yourclient.com/umbraco (!)
</rule>
<rule name="redirectUmbracoToAdminSite">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^yourclient\.com$" negate="true" />
<add input="{REQUEST_URI}" matchType="Pattern" pattern="^umbraco" ignoreCase="true" negate="false" />
</conditions>
<action type="Redirect" url="http://admin.yourclient\.com/{R:1}" />
</rule>
</rules>
I have a url rewrite in my web.config that is supposed to redirect some urls to https while ignoring some other urls.
Here is what I currently have:
<rewrite>
<rules>
<rule name="Redirect to HTTPS">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{HTTP_HOST}" pattern="localhost" negate="true" />
<add input="{HTTP_HOST}" pattern="^.qa.mysite.com" negate="true" />
<add input="{HTTP_HOST}" pattern="dev1.qa.mysite.com" negate="false" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
I works as expected by not redirecting localhost and all *.qa.mysite.com urls. It also redirects dev1.qa.mysite.com to https as expected.
The issue is that I want dashboard.mysite.com to be automatically redirected https, and I cannot figure out how to make that work.
If I add,
<add input="{HTTP_HOST}" pattern="dashboard.mysite.com" negate="false" />
, it does not work.
Any idea what am I missing?
I have a domain alias for my site. I would like to know how to redirect requests for domainA.ext to https://domainA.ext/folderA and requests for domainB.ext to http://domainB.ext/folderB
Presently I have the following rule to redirect all http requests to https but it redirects ALL requests to https:
<rule name="Redirect to https" stopProcessing="true">
<match url="(.mydomain.ext*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://mydomain.ext}" redirectType="Permanent" />*
</rule>
It is Windows server 2008, but my cms is in PHP.
I can't think of something more simple than 4 different rules.
The 2 first ones for domainA.ext:
<rule name="Check path folderA" stopProcessing="true">
<match url="^folderA" negate="true" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="domainA\.ext$" />
</conditions>
<action type="Redirect" url="https://domainA.ext/folderA/" />
</rule>
<rule name="Check SSL for domainA" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="domainA\.ext$" />
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://domainA.ext/folderA/" />
</rule>
1st rule: if the path doesn't start with folderA, then it redirects to https://domainA.ext/folderA/
2nd rule: if HTTPS is off, it redirects to https://domainA.ext/folderA/
And the 2 next ones for domainB.ext:
<rule name="Check path folderB" stopProcessing="true">
<match url="^folderB" negate="true" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="domainB\.ext$" />
</conditions>
<action type="Redirect" url="http://domainB.ext/folderB/" />
</rule>
<rule name="Check no SSL for domainB" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="domainB\.ext$" />
<add input="{HTTPS}" pattern="^ON$" />
</conditions>
<action type="Redirect" url="http://domainB.ext/folderB/" />
</rule>
1st rule: if the path doesn't start with folderB, then it redirects to http://domainB.ext/folderB/
2nd rule: if HTTPS is on, it redirects to http://domainB.ext/folderB/