Solved

IIS 8.5 redirection

Posted on 2014-10-22
3
515 Views
Last Modified: 2015-10-03
Hello Experts,

I have been trying to setup IIS redirection on a 2012 R2 server but things didn't turn out the way they should.

I have used URL Rewrite 2.0 to achieve this but this result is something weird like this:

http://www.http.com//domain.com/

http://http//domain.com

I'm trying to redirect non Ws to Ws. Site Bindings are set as the following:

www.domain.com (http)

domain.com (http)

https

--------------------------------------------

By the way, this script's admin panel works just fine along with sub URLs. The indexes are the ones not working.

Any tips?

Appreciated in advance.
0
Comment
Question by:gxs
  • 2
3 Comments
 
LVL 78

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
Comment Utility
please show the rule.  your web config should look like the following

<rewrite>
    <rules>
 <rule name="Redirect domain.com to www" patternSyntax="Wildcard" stopProcessing="true">
           <match url="*" />
            <conditions>
                <add input="{HTTP_HOST}" pattern="domain.com" />
            </conditions>
            <action type="Redirect" url="http://www.domain.com/{R:0}" />
        </rule>
    </rules>
</rewrite>
0
 
LVL 1

Author Comment

by:gxs
Comment Utility
I guess I need to elaborate a little bit to make you see the whole image.

Here is my wwwroot web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <location inheritInChildApplications="false">
    <system.webServer>
      <modules>
        <add name="OwaUrlModule" type="Microsoft.Exchange.HttpProxy.OwaUrlModule,Microsoft.Exchange.OwaUrlModule,Version=15.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35" preCondition="" />
      </modules>
    </system.webServer>
    <system.web>
      <machineKey validationKey="AutoGenerate,IsolateApps" />
      <compilation defaultLanguage="c#" debug="false">
        <assemblies>
          <add assembly="Microsoft.Exchange.OwaUrlModule, Version=15.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        </assemblies>
      </compilation>
    </system.web>
  </location>
    <system.webServer>
        <httpRedirect enabled="true" destination="https://mail.********.com/owa" childOnly="true" />
    </system.webServer>
</configuration>

Open in new window





and here is my website's web.config (it is a php script):

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="^api/?(.*)$" ignoreCase="false" />
                    <action type="Rewrite" url="webservice/dispatcher.php?url={R:1}" appendQueryString="true" />
                </rule>
                <rule name="Imported Rule 2" stopProcessing="true">
                    <match url="^([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$" ignoreCase="false" />
                    <action type="Rewrite" url="img/p/{R:1}-{R:2}{R:3}{R:4}.jpg" />
                </rule>
                <rule name="Imported Rule 3" stopProcessing="true">
                    <match url="^([0-9]+)\-([0-9]+)(-[0-9]+)?/.+\.jpg$" ignoreCase="false" />
                    <action type="Rewrite" url="img/p/{R:1}-{R:2}{R:3}.jpg" />
                </rule>
                <rule name="Imported Rule 4" stopProcessing="true">
                    <match url="^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$" ignoreCase="false" />
                    <action type="Rewrite" url="img/p/{R:1}/{R:1}{R:2}{R:3}.jpg" />
                </rule>
                <rule name="Imported Rule 5" stopProcessing="true">
                    <match url="^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$" ignoreCase="false" />
                    <action type="Rewrite" url="img/p/{R:1}/{R:2}/{R:1}{R:2}{R:3}{R:4}.jpg" />
                </rule>
                <rule name="Imported Rule 6" stopProcessing="true">
                    <match url="^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$" ignoreCase="false" />
                    <action type="Rewrite" url="img/p/{R:1}/{R:2}/{R:3}/{R:1}{R:2}{R:3}{R:4}{R:5}.jpg" />
                </rule>
                <rule name="Imported Rule 7" stopProcessing="true">
                    <match url="^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$" ignoreCase="false" />
                    <action type="Rewrite" url="img/p/{R:1}/{R:2}/{R:3}/{R:4}/{R:1}{R:2}{R:3}{R:4}{R:5}{R:6}.jpg" />
                </rule>
                <rule name="Imported Rule 8" stopProcessing="true">
                    <match url="^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$" ignoreCase="false" />
                    <action type="Rewrite" url="img/p/{R:1}/{R:2}/{R:3}/{R:4}/{R:5}/{R:1}{R:2}{R:3}{R:4}{R:5}{R:6}{R:7}.jpg" />
                </rule>
                <rule name="Imported Rule 9" stopProcessing="true">
                    <match url="^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$" ignoreCase="false" />
                    <action type="Rewrite" url="img/p/{R:1}/{R:2}/{R:3}/{R:4}/{R:5}/{R:6}/{R:1}{R:2}{R:3}{R:4}{R:5}{R:6}{R:7}{R:8}.jpg" />
                </rule>
                <rule name="Imported Rule 10" stopProcessing="true">
                    <match url="^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$" ignoreCase="false" />
                    <action type="Rewrite" url="img/p/{R:1}/{R:2}/{R:3}/{R:4}/{R:5}/{R:6}/{R:7}/{R:1}{R:2}{R:3}{R:4}{R:5}{R:6}{R:7}{R:8}{R:9}.jpg" />
                </rule>
                <rule name="Imported Rule 11" stopProcessing="true">
                    <match url="^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$" ignoreCase="false" />
                    <action type="Rewrite" url="img/p/{R:1}/{R:2}/{R:3}/{R:4}/{R:5}/{R:6}/{R:7}/{R:8}/{R:1}{R:2}{R:3}{R:4}{R:5}{R:6}{R:7}{R:8}{R:9}{R:1}0.jpg" />
                </rule>
                <rule name="Imported Rule 12" stopProcessing="true">
                    <match url="^c/([0-9]+)(\-[_a-zA-Z0-9-\.*]*)(-[0-9]+)?/.+\.jpg$" ignoreCase="false" />
                    <action type="Rewrite" url="img/c/{R:1}{R:2}{R:3}.jpg" />
                </rule>
                <rule name="Imported Rule 13" stopProcessing="true">
                    <match url="^c/([a-zA-Z-]+)(-[0-9]+)?/.+\.jpg$" ignoreCase="false" />
                    <action type="Rewrite" url="img/c/{R:1}{R:2}.jpg" />
                </rule>
                <rule name="Imported Rule 14" stopProcessing="true">
                     <match url="^.*$" />
                     <conditions logicalGrouping="MatchAny">
                         <add input="{REQUEST_FILENAME}" matchType="IsFile" pattern="" ignoreCase="false" />
                         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" pattern="" ignoreCase="false" />
                     </conditions>
                     <action type="None" />
                 </rule>
                 <rule name="Imported Rule 15" stopProcessing="true">
                    <match url="^.*$" />
                     <action type="Rewrite" url="index.php" />
                </rule>
                <rule name="Remove www" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^********.com$" />
                    </conditions>
                    <action type="Redirect" url="www.********.com/{R:0}" />
                </rule>
            </rules>
        </rewrite>
        <httpRedirect enabled="false" />
    </system.webServer>
</configuration>

Open in new window


Here are the website's binding settings:

Bindings.png
Here are the website's DNS settings (Forward Lookup zone):

dns.png
By the way, it is only one static IP and one domain, do not get confused by the parts wiped out in dark blue.
0
 
LVL 1

Author Comment

by:gxs
Comment Utility
Do not worry about the last rule which removes www. I have taken it out already, but the problem is that no matter what kind of rule I apply whether rewrite Ws or not, no result.
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

First of all, clustering IIS is something you should rarely consider doing. In almost all cases, Microsoft Network Load Balancing (NLB) (http://technet.microsoft.com/en-us/library/cc758834(WS.10).aspx) is a much better solution when you need to p…
Lync server 2013 Backup Service Error ID 4049 – After File Share Migration
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now