I have .NET MVC application hosted on IIS 10 with the following URL:
https://abc-def-example.com/MyWebsite
I want to use https://abc-def-example.com instead of the above URL.
Note: MyWebsite is name of an application hosted on IIS
How do I achieve this?
Thanks in advance!
You can use the URL Rewrite Rule to rewrite the request on https://abc-def-example.com to https://abc-def-example.com/MyWebsite:
<rewrite>
<rules>
<rule name="Test">
<match url="^(?!MyWebsite)(.*)" />
<action type="Rewrite" url="/MyWebsite/{R:0}" />
</rule>
</rules>
</rewrite>
Apply this rule to https://abc-def-example.com.
Related
I have the following website configuration on IIS 10.
<rewrite>
<rules>
<rule name="Rule1">
<match url=".*" />
<action type="Rewrite" url="https://www.google.com/{R:0}" />
</rule>
</rules>
</rewrite>
I'm trying to rewrite all the requests sent to mydomain.com to google.com (taken as an example)
When running the website, I'm getting the following google error page in the screenshot. Means the rewrite is not behaving properly and doesn't send requests to the domain www.google.com
Can anyone help please ?
Thanks. Regards,
I have hosted an Orchard site locally on my machine on IIS 8.0 using SQL LocalDb.
I have also installed and integrated the URL Rewrite module in IIS.
I have modified the web.config in the Orchard.Web project for redirecting as
<rewrite>
<rules>
<rule name="Redirect services to expertise" stopProcessing="true">
<match url="/services/(.*)" />
<action type="Redirect" url="/expertise/{R:1}" />
</rule>
</rules>
</rewrite>
So, what I intend to do is redirect from "http://localhost:70/Orchard/services/content-management" to "http://localhost:70/Orchard/expertise/content-management".
But this is not working as intended and there is no redirection. It opens up the same old "../services/.." URL.
Any Ideas?
Thanks in Advance.
I believe the issue is with your rule. The url does not have a leading slash. Try change the rule to:
<rule name="Redirect services to expertise" stopProcessing="true">
<match url="^services/(.*)" />
<action type="Redirect" url="expertise/{R:1}" />
</rule>
This will redirect any url starting with services/... to expertise/...
I have two domains: first.com and second.com.
In these domains there are two ASP.NET applications hosted in IIS 7.
Page in application http://first.com.index references a script which source is http://second.com/script.js
Script is doing some ajax POST but browser is blocking is because cross domain restriction.
Is it possible to create rule on IIS so a specific request for http://first.com/script.js
would be passed to http://second.com/script.js (executed there and returned to client) ?
I tried to add rewrite rule in first.com but it does not work:
<system.webServer>
<rewrite>
<rules>
<rule name="test" enabled="true" stopProcessing="false">
<match url=".*/script.js" />
<action type="Rewrite" url="http://second/script.js" appendQueryString="false" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
Action type="Redirect" works but it is not what I am looking for cause it returns 302 response to client. I want pass request directly to second application instead.
I have written an app to replace a single page and need to redirect the requests for the old page to the new app.
In IIS, how would I redirect the request for
http://www.mysite.com/foo.aspx
to
http://www.mysite.com/bar/default.aspx
Thanks!
In your web.config do:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Foo_To_Bar" stopProcessing="true">
<match url="^foo.aspx" />
<action type="Redirect" url="/bar/default.aspx" redirectType="Temporary" />
</rule>
</rules>
</rewrite>
</system.webServer>
If you don't want to write the redirects by hand, there is a tool for URL Rewrite and Redirects: http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module The installer says it is for 7.0 but it works with 8.5 as well.
What you need is URL rewriting. There are a number of options. Some are discussed in this question:
IIS URL Rewriting vs URL Routing
I have a REST service and am trying to remove the .svc - a common task/problem.
The application on the server is in a virtual directory under the default website (not sure if this is important)
I have installed the IIS Rewrite Module and have tried to create a rewrite rule for this.
http://blah.me.com/here/thingys/get?id=1111
to rewrite to this:
http://blah.me.com/service.svc/thingys/get?id=1111
In my web.conf the following is created:
<rewrite>
<rules>
<rule name="GEAPI /here/ to /service.svc/">
<match url="^(.*?)/here/(.*)$" />
<action type="Rewrite" url="{R:1}/service.svc/{R:2}" />
</rule>
</rules>
</rewrite>
In the GUI the regular expression does test correctly.
However - when I run this in a browser on the server, it gives the following 404 error:
Error Code 0x80070002
Requested URL http://blah.me.com:80/here/thingys/get?id=1111
Physical Path C:\MyApp\here\thingys\get
C:\Myapp is the correct physical directory the virtual directory in IIS is pointing to.
Is there something I am missing here ? I have tried creating this rule under both the default website and the app, both separately and together.
Big thanks
P
You could use this:
<rewrite>
<rules>
<rule name="GEAPI /here/ to /service.svc/">
<match url="^(.*)here(/.+)" />
<action type="Rewrite" url="{R:1}service.svc{R:2}" />
</rule>
</rules>
</rewrite>
IIS will only give you the part of the URI that's after http://blah.me.com/