1

I currently access a hosted site at this URL: http://10.1.1.165:3013, but I would like to access it like http://10.1.1.165/m2m. How can I do this? I have installed the HTTP Redirect Module and tried using it with a website bound to port 3013, but it did not work. I also have the URL Rewrite Module installed. I am using Windows 7.

1
  • I did find a solution, and it's here.
    – xinthose
    Jul 11, 2018 at 13:21

1 Answer 1

2

Couple things here:

1- You are going to need to be able to serve requests coming in on port 80, which your site you have configured in iis for port 3013 will not be able to do. So you'll want to make a new site listening on port 80 ONLY for the purpose of doing a redirect to http://10.1.1.165:3013 (where your site actually lives)

2- Once you have your site created listening on port 80, in iis create a new rewrite rule that directs traffic coming in to "http://{HTTP_HOST}:3013/{R:0}"

Steps for this are pretty simple. There is a really good MS kb here:

https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/using-rewrite-maps-in-url-rewrite-module

the rewrite mapping would be something like:

    <?xml version="1.0" encoding="UTF-8"?>
 <configuration>
<system.webServer>
    <directoryBrowse enabled="true" showFlags="Date, Time, Size, Extension, LongDate" />
    <rewrite>
        <rules>
            <rule name="Redirect to port 3013" stopProcessing="true">
                <match url="http://10.1.1.165/^m2m/([0-9]+)/([_0-9a-z-]+)" />
                <conditions logicalGrouping="MatchAny">
                    <add input="{SERVER_PORT}" pattern="^3013$" negate="true" />
                </conditions>
                <action type="Redirect" url="http://{HTTP_HOST}:3013/{R:0}" />
            </rule>
        </rules>
    </rewrite>
 </system.webServer>
</configuration>
4
  • Thank you. I am going to need more steps in IIS. Click "Default Web Site" then "URL Rewrite" then "Add Rule(s)..." then "Rule with rewrite map", then I get lost.
    – xinthose
    Jul 9, 2018 at 20:53
  • 1
    Added a link to the microsoft kb on creating rewrite mappings to the original answer :) Jul 9, 2018 at 21:04
  • My problem is that my requested URL becomes http://10.1.1.165:80/:3013
    – xinthose
    Jul 11, 2018 at 13:09
  • The main problem is the variable {HTTP_HOST} which already contains the PORT information. You can change rule as: <action type="Redirect" url="http://{C:1}:8100/{R:0}" /> Apr 6, 2022 at 10:22

Not the answer you're looking for? Browse other questions tagged .