Virtual Directories Configure External and Internal URL in Microsoft Exchange Server 2013.
Virtual Directories Exchange 2013
Open Exchange Admin Center.
1- Select Servers > Virtual Directory and then select the External Access Domain settings button.

2- On the configure external access domain then click the add + button.

3- Select the Exchange 2013 server(s) you wish to configure external URLs on, Then click Add button, once you have all the required servers then click ok.
In my Labe, I will be able to just be configuring Exch2013-1 but you’ll select as many servers as you wish.

4- Enter the domain name you wish to use externally. In my case I want our external users to go to mail.xpertstec.com, then click Save.

5- This may take some time. Once complete so click close.

ECP Virtual Directory Exchange 2013
Set-ECPVirtualDirectory
Set-ECPVirtualDirectory –Identity “ECP (default web site)” -ExternalURL “https://mail.xpertstec.com/ECP”
Set-ECPVirtualDirectory –Identity “ECP (default web site)” -InternalURL https://mail.xpertstec.com/ECP”
Exchange Admin Center 2013 > select Servers > select Virtual Directories > select ecp (Default Web Site) and then click edit pin button.

Select the General tab, type Internal & External URL and then click save.

OWA Virtual Directory Exchange 2013
Set-OwaVirtualDirectory
Set-OWAVirtualDirectory –Identity “OWA (default web site)” -ExternalURL “https://mail.xpertstec.com/OWA”
Set-OWAVirtualDirectory –Identity “OWA (default web site)” -InternalURL “https://mail.xpertstec.com/OWA”
Exchange Admin Center 2013 > select Servers > select Virtual Directories > Select owa (Default Web Site) and then click the edit pin button.

Select the General tab, type Internal & External URL and then click Save.

ACTIVESYNC Virtual Directory.
Set-ActiveSyncVirtualDirectory
Set-ActiveSyncVirtualDirectory –Identity “Microsoft-Server-ActiveSync (default web site)” -ExternalURL “https://mail.xpertstec.com/Microsoft-Server-ActiveSync”
Set-ActiveSyncVirtualDirectory –Identity “Microsoft-Server-ActiveSync (default web site)” -InternalURL https://mail.xpertstec.com/Microsoft-Server-ActiveSync
Admin Center 2013 > select Servers > select Virtual Directories > Select Microsoft Server ActiveSync (Default Web Site) and then click edit pin button.

Select the General tab, type Internal & External URL and then click Save.

OAB Virtual Directory
Set-OABVirtualDirectory
Set-OABVirtualDirectory –Identity “OAB (default web site)” -ExternalURL “https://mail.xpertstec.com/OAB”
Set-OABVirtualDirectory –Identity “OAB (default web site)” -InternalURL “https://mail.xpertstec.com/OAB”
Exchange Admin Center 2013 > select Servers > seelct Virtual Directories > So, select owb (Default Web Site) and then click edit pin button.

Type Internal & External URL and then click on Save.

EWS Virtual Directory.
Set-WebServicesVirtualDirectory
Set-WebServicesVirtualDirectory –Identity “EWS (default web site)” -ExternalUrl “https://mail.xpertstec.com/ews/exchange.asmx”
Set-WebServicesVirtualDirectory –Identity “EWS (default web site)” -InternalUrl “https://mail.xpertstec.com/ews/exchange.asmx”
Exchange Admin Center 2013 > select Servers > select Virtual Directories > Select ews (Default Web Site) and then click edit pin button.

Select the General tab, type Internal & External URL and then click on Save.

POWERSHELL Virtual Directory.
Exchange Admin Center 2013 > select Servers > to select Virtual Directories > Select PowerShell (Default Web Site) and then click the edit button.

Select the General tab, type Internal & External URL and then click on Save.

OUTLOOK ANYWHERE
Set-OutlookAnywhere -Identity “Exch2013-1\RPC (Default Web Site)” -ExternalHostname mail.xpertstec.com -InternalHostname mail.xpertstec.com -ExternalClientsRequireSsl $true -InternalClientsRequireSsl $true -DefaultAuthenticationMethod NTLM
To confirm this change type the following. You will receive the output similar to that below.
Get-OutlookAnywhere | Select Server,ExternalHostname,Internalhostname | fl
Exchange Admin Center 2013 > select Servers > select Servers > Select Exchange server (EXCH2013-1) and then click the edit pin button.

Select Outlook Anywhere tab, type Internal & External URL and then click on Save.

AUTODISCOVER
Set-AutodiscoverVirtualDirectory
Set-ClientAccessServer -Identity Exch2013-1 -AutoDiscoverServiceInternalUri https://autodiscover.xpertstec.com/Autodiscover/Autodiscover.xml
To view the changes type
Get-ClientAccessServer | FL AutoDiscoverServiceInternalUri
Not enabled as default. Please note that the autodiscover should be set as an A-record in your DNS. Also, note that you simply don’t provide an URL for this.
Set-AutodiscoverVirtualDirectory -Identity ‘autodiscover (default Web site)’
MAPI/HTTP
Not enabled as default. Requires Exchange 2013 SP1. Clients must be Outlook 2013 or newer. Fallback is OutlookAnywhere for older clients.
Set-MapiVirtualDirectory -Identity “mapi (Default Web Site)” -InternalUrl “https://mail.xpertstec.com/mapi” -IISAuthenticationMethods NTLM,Negotiate
After fixing the VirtualDirectory you would like to enable it:
Set-OrganizationConfig -MapiHttpEnabled $true
More Information click here