I have a Sitecore application running on top of IIS 8.5. I want to redirect/rewrite from #1 to #2 URL.
http://mywebsite.com/a/a1/webpage.aspx
http://mywebsite.com/a/a2/webpage.aspx
I tried to do on IIS-URL rewrite level, it just doesn't work and nothing happen.
<rule name="redirect_a1_to_a2" enabled="false" stopProcessing="true">
<match url="a/a1/" />
<conditions>
<add input="{PATH_INFO}" pattern="a/a1(/?)" />
</conditions>
<action type="Redirect" url="http://mywebsite.com/a/a2" />
</rule>
Please help.
Your rule is correct. Then only thing you need to do is to enable the rule.
Just change:
enabled="false"
to
enabled="true"
Related
I'm creating an application that accepting users as sub-domains,
Ex: {user_id}.mywebsite.com, thus, every request has to be *.mywebsite.com.
Problem is that every sub domain has to be bind on the iis
user1.mywebsite.com
user2.mywebsite.com etc etc
My question is, is there a way to set a domain site to accept every sub-domain request?
This is basically what I want to do
Is there any way to do it without adding every user as sub-domain to the iis site?
Thanks in advance.
You can set up a catch-all site and then use ARR to forward the traffic,
<system.webServer>
<rewrite>
<rules>
<rule name="site1" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(.*).site1.com$" />
</conditions>
<action type="Rewrite" url="http://localhost:8091/{R:0}" />
</rule>
<rule name="site2" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(.*).site2.com$" />
</conditions>
<action type="Rewrite" url="http://localhost:8092/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
Other supporting steps can be found in this blog post,
I have some old URLs in a forum application points to http://mydomain.tld/showthread.php?p=xxxx where xxxx is the an integer id.
My new forum application uses viewtopic.php?p=xxxx and I want to handle this using IIS web.config rewrite rules.
I have tried to add the last rule as the following:
<rewrite>
<rules>
<rule name="Redirect www to non www" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(.*)" />
<action type="Redirect" url="http://domain.tld/{R:1}" />
<conditions>
<add input="{HTTP_HOST}" pattern="^domain\.tld" negate="true" />
</conditions>
</rule>
<!-- this for change from showthread.php to viewtopic.php -->
<rule name="Rewrite" stopProcessing="true">
<match url="(.*)showthread\.php" />
<action type="Rewrite" url="viewtopic\.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
However, it does not able to redirect to the viewtopic.php. Any suggestion?
I have to enable httpRedirect in the IIS. Then I used this redirect rule in the web.config at the root of my forum:
<httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
<add wildcard="*showthread.php" destination="/viewtopic.php?$P" />
</httpRedirect>
I want to redirect anything to https://domain.com
I found this code:
<rewrite>
<rules>
<rule name="SecureRedirect" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{HTTPS}" pattern="off" />
<add input="{HTTP_HOST}" pattern="^(www\.)?(.*)$" />
</conditions>
<action type="Redirect" url="https://{C:2}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
And its working except on https://www.domain.com
My virtual server is Windows Server 2012 with IIS 8, and the domain is https://kajsystem.com
I would suggest using IIS 8 configurations including using the URL Rewrite module, which can handle forwarding and retain the entire requested URL. There is a fairly comprehensive article on MSDN site covering this:
MSDN redirect on IIS 7 and higher
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!
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>