简体   繁体   中英

IIS 7.5 URL Rewrite not working? help please

I am trying to get a URL rewrite so it takes a URL for eg my.site.com and rewrites it to "Http://localhost:8080". I keep getting default homepage instead of it being redirected. I have configured the rewrite as follows :

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
    <rewrite>
        <rules>
            <rule name="mysite">
                <match url="(my.+)" />
                <action type="Rewrite" url="http://localhost:8080" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>
</configuration>

I am at a loss, is there something I am doing wrong ???

Any help will be greatly appreciated.

Cheers Jeff

It is not 100% clear what you want to achieve and why, but because localhost is involved, it seems you do not want to rewrite but maybe perform a http redirect . Rewriting means that your request URL is sort of changed into another one, like index_foo.htm could be rewritten to index.aspx?what=foo.

But you want to change the domains, so you need to redirect . Try:

<system.webServer>
    <httpRedirect enabled="true" destination="http://localhost:8080" childOnly="false" />
</system.webServer>

This will keep whatever local page you have called, ie my.site.com/foo.htm will be redirected to localhost:8080/foo.htm.

Because this looks like a temporary thing for development purposes, you can add

 httpResponseStatus="Temporary"

to httpRedirect (may be important in order not to lose search engine rankings).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM