I've browser a lot of similar questions here, but most have complicated parameters associated with them. I'm just looking to 301 redirect one link to another on the same domain. The to and from links are very specific, so I don't need to account for any wildcards.
In web.config what would be the appropriate way to 301 redirect /locations/100-denver to /locations/denver?
<configuration>
<system.webServer>
<rewrite>
<rewriteMaps>
<rewriteMap name="Redirects">
<add key="/test.aspx" value="/test2.aspx" />
<add key="/aboutus.aspx" value="/about" />
</rewriteMap>
</rewriteMaps>
</rewrite>
</system.webServer>
</configuration>
I was just researching a similar subject and found this answer on another page: enter link description here
Related
I have a react web application that I'm hosting on a Windows Server.
In IIS I created URL Rewrite rules. When I view the website from within our network the rewrite rules work and it redirects from HTTP to HTTPS.
However since port 80 is closed on the public side when i try to view the website in HTTP it never redirects and just times out. I'm assuming that's because it never actually hits the page since the port is closed so the redirect never kicks in.
Is there a way to still get the website to redirect to HTTPS with that port closed?
Here is how my web.config file looks:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
<httpRedirect enabled="false" destination="https://mywebsitehere.com" />
<rewrite>
<rules>
<rule name="http to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://mywebsitehere.com/{R:1}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
The answer is No, in order for any form of HTTP redirection to work within the server, the server must be capable of getting the incoming connection HTTP request on port 80, It would then send a 3xx response to tell the browser to try again with a different URL, That URL would be an HTTPS URL. If the HTTP request is closed before the server gets it, naturally it can't do anything.
basically i wanna to rewrite url using reverse proxy:
from:
http://www.xyz.in/eacc/api/fetchVendors
to
http://localhost:8080/eacc/api/fetchVendors
I have deployed my spring boot rest full web service application in tomcat under C:\Tomcat\apache-tomcat-9.0.7\webapps\eacc.
It contains many POST call like /eacc/api/fetchVendors, /eacc/api/users, /eacc/api/clients.. etc.
Now i wanna to expose this eacc rest application through IIS.
have main website configured called www.xyz.in.
added virtual directory under website (www.xyz.in) called /eacc.
physical path: C:\inetpub\wwwroot\eacc
below is web.config file.
When i try to hit one post call like www.xyz.in/eacc/api/fetchVendors, getting HTTP 404 server error.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /eacc/api/fetchVendors
My web.config file for /eacc - virtual directory
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpRedirect enabled="false" />
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:8080/eacc/{R:1}" />
</rule>
</rules>
<outboundRules>
<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
<match filterByTags="A, Form, Img" pattern="^http(s)?://localhost:8080/eacc/(.*)" />
<action type="Rewrite" value="http{R:1}://www.xyz.in/{R:2}" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/(.+)" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>
Am new to IIS web server.have stuck with URL Rewrite reverse proxy pattern. have tried many pattern changes but no luck. Looking help from anyone.
For me, this worked on IIS:
Go to IIS root node >> ARR
Click "Server Proxy Settings" option
and enable it:
Inbound Rule:
Use Patters : ^eacc.*
Rewrite URL : http://localhost:8080/{R:0}
Outbound Rule:
Pattern : localhost:8080
Value : www.xyz.com
Also you need to Add Proxy settings (Application Request Routing Module - Server Proxy settings) :
(tick) Enable Proxy
(untick) REverse Rewrite in response headers
I have many websites hosted on the same IIS. When I stop one of them, and trying accessing it, it renders the default website of IIS. i.e iisstart.htm.
What I need to have is, for example, when example1.com has been stopped and trying to access its home page or better any URL on it i.e example1.com/some/path it redirects to an other defined page on the root of the default website, such as, example1.html. Also, I need the solution to be applied as many as websites that I have, i.e example2.com, example3.com and so on.
I have tried the following web.config settings, but it does not work:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="conditional products redirect" enabled="true">
<match url="^example1(.*)" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="/example1.html" />
</conditions>
<action type="Redirect" url="/example1.html" appendQueryString="false" redirectType="Found" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I was looking into this Seemingly simple redirect in IIS using web.config file because I have a similar situation, but the approach mentioned there doesn't seem to be working for me.
I have a help section on a web site, which for now I want it to redirect to another place. The rest of the site should stay the same, which means that only the help section/content should make the user go to another site:
device.domain.com/help
device.domain.com/help/version
Should make the request go to
company.custhelp.com
But for example device.domain.com/api should still work. This is what I tried. If I test the pattern inside of IIS it says that it will work. What am I missing?
<system.webServer>
<rewrite>
<rules>
<rule name="Help Redirect" stopProcessing="true">
<match url="(.*)/help(.*)" ignoreCase="true" />
<action type="Redirect" url="http://company.custhelp.com/" appendQueryString="false" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
...
</system.webServer>
The match url will try to match on the path after the domain, starting from after the slash. So it should be like so:
<match url="help(.*)" ignoreCase="true" />
The match url that you wrote would match on device.domain.com/temp/help, but not device.domain.com/help.
I'm trying to use a separate config file, named "rewritemaps.config", that contains the URLs I want to redirect. The file is in the root directory (same place as the web.config). The format of the Redirects.config file I have is:
<rewriteMaps>
<rewriteMap name="Redirects">
<add key="aspx/drvmain.aspx"
value="http://www.newdomain.com/folder2/page2.aspx" />
<add key="aspx/jobs_AboutUs.aspx"
value="http://www.newdomain.com/folder1/jobs.aspx" />
<add key="aspx/page.aspx"
value="http://www.newdomain.com/folder1/page2.aspx" />
</rewriteMap>
</rewriteMaps>
In my web.config file, I have:
<system.webServer>
<rewrite>
<rewriteMaps configSource="rewritemaps.config" />
<rules>
<rule name="Redirect rules">
<match url=".*" />
<conditions>
<add input="{Redirects:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Redirect" redirectType="Permanent"
url="{C:1}" appendQueryString="false" />
</rule>
</rules>
</rewriteMaps>
</rewrite>
</system.webServer>
In the IIS Manager (which, yes, I have installed the URL Rewrite module), I've even gone and tested the rule and condition against one of my URLs in the redirects.config file and it says it works. But then when I try going to the URL in my browser, it doesn't redirect as I've specified. In the rewritemaps.config file, I've tried putting the full domain, and I've tried with a "/" before aspx. Nothing seems to work. I'm not sure what I'm missing here.
Well I got it working. Was something stupid. In the rewritemaps.config file, I needed "/"s before the key URL. I know I had tried that before, but I must have been missing something somewhere else at the time. Oh well. It works now.
It is really hard to determine why this is failing but the best thing you can do is use Failed Request Tracing so that IIS tells you what is happening. With FREB you will get detailed tracing telling you which rules were evaluated and if they matched or they didn't and why not. You can also see the "right" patterns to match and every condition that is evaluated.
See the following link:
http://www.iis.net/learn/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules