If you are migrating from Exchange 2010 to Exchange 2013 then you may come across this issue. If your Exchange organization is quite large then you will be more than aware that it can take days if not weeks to migrate all the mailboxes from the old Exchange 2010 server to the new Exchange 2013 server.
During this process you will move your external OWA (Outlook Web Access ) A record such as https://mail.yourdomain.com/owa to your new Exchange 2013 CAS server by changing port 443 on your firewall to port to the new server. This is where the problem may arise.
If you have moved say half of your mailboxes to Exchange 2013 then when these users connect to https://mail.yourdomain.com/owa then they will get the correct owa authentication screen as seen below.
However if you have a mailbox that is still on Exchange 2010 and you try to connect to OWA then it will not redirect to Exchange 2013, instead you will be directed to an IIS7 screen or the Exchange OWA screen will not be displayed correctly. To fix this we do the following. REMEMBER ALWAYS TAKE A BACKUP OF THESE FILES BEFORE WE MODIFY THEM.
Browse to the following.
We now need to remove the following from the web.root file. Then save.
!-- modules add name="OwaUrlModule" type="Microsoft.Exchange.HttpProxy.OwaUrlModule,Microsoft.Exchange.OwaUrlModule,Version=220.127.116.11, Culture=neutral,PublicKeyToken=31bf3856ad364e35" preCondition="" / /modules --!
Then add the following text.Copy and paste the text below as seen in the image replacing https://yourexchange2013server/owa with your internal url for your exchange 2013 server.