I'm trying to simply do a subdomain rewrite to a directory. Example, http*://member.mydomain.com would redirect to http*://mydomain.com/memberarea/. I don't want ALL subdomains to do this, just the defined "member" one.
Here is the code I have, and it does not work. I'm obviously missing something...
<rule name="Member Pages" stopProcessing="true">
<match url="^(.+)" />
<conditions>
<add input="{HTTP_HOST}" pattern="(.*)://member\.example\.com($)" />
</conditions>
<action type="Redirect" url="{C:1}://example.com/MemberArea/{R:1}" />
</rule>
My hope is this would also make http://member.example.com/Report/SomeReport.aspx resolve to http://example.com/MemberArea/Report/SomeReport.aspx.
Any help would be greatly appreciated.
You can try this rule will be redirected to the http*://member.mydomain.com http*://mydomain.com/memberarea/
<rule name="test2" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^member\.(.*)$" />
</conditions>
<action type="Redirect" url="http://{C:1}/memberarea" />
</rule>
Related
I am a fairly novice windows IIS guy, so any help I would greatly appreciate.
I have a client that requested all root Urls on their department websites redirect to their index.html page. So if a user, for example, goes to https://mysite.domain.com/, it will redirect to https://mysite.doman.com/index.html.
I did this through IIS 10 using a URLrewrite rule on the root of each site by doing the following.
<rule name="Index Request" enabled="true" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="https://mysite.domain.com/index.html" />
</rule>
This seemed to work.
The client now wants to have any of the subfolders of the root site show the index.html to any subdirectory sites of the root. Example. Https://mysite.domain.com/subdir/ “This is what shows now” to https://mysite.domain.com/subdir/index.html. Is there a way to do this in IIS?
Thanks in advance for any advice
I have made sure the index.html is the default document. I have also looked at User Friendly URL-template https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/user-friendly-url-rule-template, but I am not sure if this is the right direction to go.
You can try this rule:
<rule name="test" enabled="true" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="/index.html" />
</rule>
<rule name="test1" enabled="true" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{REQUEST_URI}" pattern="^/([^/]+)" />
</conditions>
<action type="Redirect" url="/{C:1}/index.html" />
</rule>
<rule name="SEF Rule" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}/index.html" matchType="IsFile"
ignoreCase="false" />
</conditions>
<action type="Redirect" url="{R:1}/index.html" />
</rule>
I have an aspx web app accessed via http://domain/web.aspx. This web app uses port 80 and http://domain:80/web.aspx works OK. I would like to redirect all calls to https://domain:82/web.aspx. I've tried using the rewrite rule
<rule name="HTTPS force" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(.*):80$" />
</conditions>
<action type="Redirect" url="https://localhost:82" appendQueryString="false" />
</rule>
in web.config in the same folder as web.aspx but this has no effect. What rewrite rule do I need to use?
You should use the following as input:
<rule name="HTTPS force" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="Permanent" />
</rule>
Not sure if you want the :80 there in the URL? If so, it can be added to my example too. Taken from here: Web.config redirects with rewrite rules - https, www, and more.
Found this rule worked
<rule name="HTTPS force" enabled = "true" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="http://domain/Web.aspx" />
</conditions>
<action type="Redirect" url="https://domain:82/Web.aspx"/>
</rule>
I am using IIS url rewrite rule to redirect from an IP Address to a domain name with the following rule.
<rule name="IPHit" enabled="true" stopProcessing="false">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="10.32.1.132" />
</conditions>
<action type="Redirect" url="https://daart-qa.sandbox.aimsplatform.com/eds-daas/{R:1}" redirectType="Permanent" appendQueryString="true" />
</rule>
Unfortunately, this results in an infinite loop redirect when I go to https://daart-qa.sandbox.aimsplatform.com/eds-daas.
How can I redirect from the IP address without having an infinite loop on dns entry?
Your rule will redirect 10.32.1.132/eds-daas to https://daart-qa.sandbox.aimsplatform.com/eds-daas/eds-daas. Is that expected behavior?
May I know your only face this infinite loop when you access specific URL or all requests hitted by IP address. What loop URL did you see in web browser developer tool?
Post the symtptom of loop URL would help us find the root cause.
Or you need to redirect request 10.32.1.132/eds-daas to https://daart-qa.sandbox.aimsplatform.com/eds-daas? If so you may need two rules side by side.
<rule name="IPHit" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="10.32.1.132" />
<add input="{REQUEST_URI}" pattern="^/eds-daas(.*)" negate="true" />
</conditions>
<action type="Redirect" url="https://daart-qa.sandbox.aimsplatform.com/eds-daas/{R:1}" redirectType="Permanent" appendQueryString="true" />
</rule>
<rule name="IP-HIT2" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="10.32.1.132" />
<add input="{REQUEST_URI}" pattern="^/eds-daas(.*)" />
</conditions>
<action type="Redirect" url="https://daart-qa.sandbox.aimsplatform.com/eds-daas{C:1}" />
</rule>
I have multiple domain names pointed to the same server (example.nl)
The example.my url should point to the content of example.nl/en, without having this url to appear in the adress bar. This is only really necessary for the homepage (due to google addwords issues).
To summarize, example.my should show the content of example.nl/en while showing example.my in the adress bar.
The current rule is giving me an error. Any tips?
<rule name="Redirect .my" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^.*example\.my$" />
</conditions>
<action type="Rewrite" url="http://www.example.nl/en/" />
</rule>
This seems to do the trick for me:
<rule name="redirect .my to /en" enabled="true" stopProcessing="true">
<match url="(^$)" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="example.my" />
</conditions>
<action type="Redirect" url="http://www.example.my/en/{R:1}" appendQueryString="true" />
</rule>
I want to create a rewrite rule in IIS 8.5 so that the TLD in the url gets changed from .com to .net.
example:
from: http://sub.domain.com/index.aspx?test=123
to: http://sub.domain.net/index.aspx?test=123
At the moment I got something like this in my web.config but is doesn't seem to work:
<rule name="TLD" enabled="false">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www.)?([a-z]*.)(domain)(.com)(/?.*)$" />
</conditions>
<action type="Rewrite" url="http://{C:2}{C:3}.net/{C:5}" />
</rule>
Any suggestions?
I was looking for the exact same problem and found this
<rule name="WWW" enabled="true" stopProcessing="true">
<match url=" (.*)"/>
<conditions >
<add input="{HTTP_HOST}" pattern="^(www\.)?example\.old$"/>
</conditions>
<action type="Redirect" url="h++p://example.com/{R:1}" redirectType="Permanent" />
</rule>
Found it here: ReWrite top-level domain (TLD)