Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS rewrite all request to a static url

I have http://xyz.it/page1 to http://xyz.it/pageN and I need to redirect all pages to http://bar.it/foo and I thought I had solved it with this rule:

    <rule name="from-xyz-to-bar" stopProcessing="true">
        <match url=".*" />
        <conditions logicalGrouping="MatchAny">
            <add input="{HTTP_HOST}" pattern="^xyz\.it$" />
        </conditions>
        <action type="Redirect" url="http://bar.it/foo" appendQueryString="false" redirectType="Permanent" />
    </rule>

But it doesn't work. What my rule is doing is redirecting http://xyz.it/page1 to http://bar.it/page1 and I don't understand where I am wrong.

Please help!

like image 829
Max Favilli Avatar asked Jul 26 '15 22:07

Max Favilli


People also ask

What is Request_uri in URL Rewrite?

Returns exact URL what you requested. For example, if you have default.aspx file in the root and you will access your website root.

What is the difference between routing and URL rewriting?

ASP.NET routing is used to dispatch a request to a handler based on the requested URL path. As opposed to URL rewriting, the routing module knows about the handlers and selects the handler that should generate a response for the requested URL. You can think of ASP.NET routing as an advanced handler-mapping mechanism.

Does the URL in the browser change when a rewrite happens?

A rewrite is a server-side rewrite of the URL before it's fully processed by IIS. This will not change what you see in the browser because the changes are hidden from the user. Useful for search engine optimization by causing the search engine to update the URL.


1 Answers

<rule name="from-xyz-to-bar" stopProcessing="true">
    <match url="^$" />
    <action type="Redirect" url="http://bar.it/foo" />
</rule>
like image 69
davidcondrey Avatar answered Sep 19 '22 01:09

davidcondrey