IIS7.5 Direct all requests to one page - asp.net

I wish to create a site that returns the same html page for all page requests.
For example the same page will be served for all the below requests:
http://holdingsite
http://holdingsite/foo
http://holdingsite/foo/bar
http://holdingsite/foo.aspx
http://holdingsite/foo.html
What configuration is needed to ensure every request is directed to this one page?

If you can, install the URL Rewrite Module
You can then add a rewrite rule to you config
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="catchall" stopProcessing="true">
<match url=".*" />
<action type="Rewrite" url="/somepage.htm" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
N.b You can also configure this via IIS once you have installed the module

Related

Asp.Net on IIS - Add default route to url

I am trying to change the default URL of my Asp.Net website on IIS. At the moment the URL leading to the default index.html, is just http://myservername/. But I would actually prefer to extend the URL to http://myservername/route1, which then still routes to the default html. How can I achieve this?
Download Microsoft URL Rewrite Module and install it
and add this to your web.config
<system.webServer>
<rewrite>
<rules>
<rule name="Root Hit Redirect" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="/route1" />
</rule>
</rules>
</rewrite>
</system.webServer>

Can I make this web.config rewrite rule?

In web.config I would like to set up the following rule for my ASP.NET project:
A request to:
mydomain.com/123/some-page
returns page
mydomain.com/collection/123-some-page.html
In other words
domain/x/y should fetch and return domain/collection/x-y.html
The visitor should still see the domain/x/y in the browser url.
Can I make such a rewrite rule?
Remember to install url rewrite module in IIS
and set below rule in web.config
<rewrite>
<rules>
<rule name="My rewrite">
<match url="^(.*)/(.*)$" />
<action type="Rewrite" url="collection/{R:1}-{R:2}.html" />
</rule>
</rules>
</rewrite>

DNS rewrite in asp.net or DNS redirection in asp.net

I have an aspx page with some HTML tags
Example
Actual url
<img src="https://google.com/fp/clear.png?latitude=<latitude>&longitude=<longitude> alt="">
How do i change the domain name (google.com) to a local URL (localgoog.com), and configure web server to redirect the URL (localgoo.com) to actual url (google.com)
Since you're referring to an aspx page, I'm assuming you're running on IIS. In that case, you may install the URLRewrite module into your IIS server. http://www.iis.net/downloads/microsoft/url-rewrite
Then, within IIS management console, you may setup a rewrite rule to redirect any url coming in with the hostname of "localgoo.com" to "google.com". Once you save this rule, your web.config file will be modified to include the XML version of your rewrite rule, which then makes your app portable to other servers as well.
<system.webServer>
<rewrite>
<rules>
<rule name="RedirectToGoogle" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^localgoo.com$" />
</conditions>
<action type="Redirect" url="//google.com/{R:0}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
The {R:0} is a captured group of anything that comes after the hostname and appends it back onto the new hostname.

IIS URL Redirect works, but Rewrite throws 403 forbidden error

I have a web.config file in a subdirectory of an IIS application like this
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Proxy2" stopProcessing="true" patternSyntax="Wildcard">
<match url="*" ignoreCase="true"/>
<conditions>
<add input="{HTTP_HOST}" pattern="*" />
</conditions>
<action type="Rewrite" url="http://anotherurl.com/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
so, if I browse https://www.abc.com/subdir , it will return 403 forbidden error. but if I change the action to redirect, it will redirect without problems. what should I look for to find the problem?
It's not possible to rewrite to another URL (or another Application Pool). Only redirect will work in this case.
Edit: Technically it's possible, but not the way you've implemented it. If you want to rewrite to another URL, you'll need to implement as a reverse proxy using the Application Request Routing (ARR) module in IIS.

iis7 redirect from exact url to new site

I want to re-direct from an exact URL request to a new site within that domain.
I need to re-direct requests from
www.example.com/site111/default.aspx?configX.xml
(this site uses a different config file to load content)
to
www.example.com/site222/default.aspx
Issue is that I need to leave access www.example.com.au/site111/default.aspx
so I cannot just to a http re-direct as there is no file called default.aspx?configX.xml
I think I need to use a URL rewrite re-direct
Can someone help me with the syntax for the web config I cannot get it to work
0 module installed and have used the above syntax and it still doesn't work,
If I use the test feature on the module it says that the string matches,
very confused,
the actual webconfig section is here
<rewrite>
<rules>
<rule name="Redirect2" stopProcessing="true">
<match url="\/nrmmaps\/default.aspx\?config=nrmproject.xml$" />
<action type="Redirect" url="/nrmproject/default.aspx" redirectType="Permanent"/>
</rule>
</rules>
</rewrite>
and the old link is
http://se.nrmspace.com.au/nrmmaps/default.aspx?config=nrmproject.xml
and I want it to re-direct to
http://se.nrmspace.com.au/nrmproject/default.aspx
Do you have any idea why this is not working?
I believe you need to install the IIS rewrite module which can be found here:
http://www.iis.net/downloads/microsoft/url-rewrite
After you do that, you can add a rewrite section with a redirect rule in your web.config like so:
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect" stopProcessing="true">
<match url="\/site111\/default.aspx\?configX.xml$" />
<action type="Redirect" url="/site222/default.aspx" redirectType="Permanent"/>
</rule>
</rules>
</rewrite>
</system.webServer>
Hope this helps

Resources