Showing posts with label website. Show all posts
Showing posts with label website. Show all posts

Thursday, 6 October 2016

IIS - Make OWA the Default Website Page

After installing Microsoft Exchange, a "virtual directory" for Outlook Web Access (OWA) is created that is generally accessible via the URL https://mail.yourdomain.com/owa

In some scenarios it may be preferable to configure https://mail.yourdomain.com to redirect automatically to the OWA virtual directory (as users may forget to include this part if they are manually typing the URL). This means as soon as they try to access the root domain website, they are automatically presented with a login page for OWA.

It is very easy to configure, as per the steps below;

  1. Open Internet Information Services (IIS) Manager (from Control Panel > Administrative Tools)
  2. Expand the tree from the left hand side and highlight/select Default Web Site

  3. Double click the HTTP Redirect icon from the main window

  4. Select the option to Redirect requests to this destination and enter /owa into the text box below
    Select the option to Only redirect requests to content in this directory (not subdirectories). Ensure the status code is set to Found (302)

  5. Click Apply in the top right corner to apply the changes
  6. Try accessing the base URL again and you should be automatically redirected to the OWA login page



Friday, 28 March 2014

Check/Monitor Website URL with Powershell

Windows Powershell has a built in web request module that you can use to test/check the availability of website URL(s).

The full script to do this is below;

[string] $url = "http://www.google.com"
[net.httpWebRequest] $req = [net.webRequest]::create($url)
$req.method = "HEAD"
[net.httpWebResponse] $res = $req.getresponse()

The first line is self explanatory - simply put in the full URL for the website you wish to check. In this example we will be checking http://www.google.com

[string] $url = "http://www.google.com"

The second line is where we create the actual web request instance in Powershell - under the $req variable

[net.httpWebRequest] $req = [net.webRequest]::create($url)

On the third line, we change the request method to be "HEAD" which means that only header information for the requested URL is retrieved. This speeds up the web request process as it does not pull all the data from the web URL - only the header information. If you leave this line out, the default method is "GET".

$req.method = "HEAD"

On the last line we actually submit the web request, and store the response in the $res variable

[net.httpWebResponse] $res = $req.getresponse()

For a successful web request, the response should look something like this:

IsMutuallyAuthenticated : False
Cookies                 : {}
Headers                 : {Cache-Control, Content-Type, Date, Expires...}
ContentLength           : -1
ContentEncoding         : 
ContentType             : text/html; charset=ISO-8859-1
CharacterSet            : ISO-8859-1
Server                  : gws
LastModified            : 28/03/2014 10:24:19 AM
StatusCode              : OK
StatusDescription       : OK
ProtocolVersion         : 1.1
ResponseUri             : http://www.google.com.au/?gfe_rd=cr&ei=I7M0U5P_BenC8gfRvIHADg
Method                  : HEAD
IsFromCache             : False

Based on this, you could check the statuscode or statusdescription properties of $res to make sure the value matches "OK".

Alternatively, if you enter an invalid URL for a website that doesn't exist, you will get an error, and the value of $res will be $null. The error you get will be something along the lines of;

Exception calling "GetResponse" with "0" argument(s): "The remote server returned an error: (502) Bad Gateway."
At line:4 char:46
+ [net.httpWebResponse] $res = $req.getresponse <<<< ()
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException