IIS8 – SEARCH ENGINE OPTIMIZATION(SEO)

In this post we are going to optimize website that hosted in IIS8 implementing basic SEO rule to help improve better user experience at the same time increase SEO ranking.

According to Google’s Search Engine Optimization Starter Guide we will optimize our IIS application.

Let’s get stepped into it. First of all we will get basic overview on IIS8 and SEO.

IIS8: Microsoft’s Internet Information Server (IIS) is an extensible web Server that host multiple web application/site.

IIS supports HTTP, HTTPS, FTP, FTPS, SMTP and NNTP.

Other’s web servers include

  1. Apache,
  2. NGNIX (pronounced engine X) from NGNIX.
  3. Novell’s NetWare server,
  4. Google Web Server (GWS) and
  5. IBM’s family of Domino servers.

SEO: SEO is a process to improve the visibility of a website in search engine results. Learn more from GOOGLE SEO GUIDE

Table of Content:

  1. Improving Site Structure
    • Sitemap
  2. Dealing with Crawlers
    • robot.txt
    • BOT accessibility(Libwww-perl Access)
  3. Server Security
    • Server Signature (Server: Microsoft-IIS/8.0)
  4. Canonicalization
    • URL Canonicalization
    • IP Canonicalization
  5. Optimizing Content
    • Page Cache (Server Side Caching)
    • Expires Tag
    • HTML Compression/GZIP

Let’s get details about those topics with an basic sample application hosted in IIS. First of all we need to configure IIS to host our website. We will change windows host file to set hostname with local ip and port.

Modification of Host file, browse file : c:\Windows\System32\Drivers\etc\hosts

seo1

hit enter and then open with notepad, copy content to another opened note(open with Run as administrator) paste content > make changes > Save with replace host file.

seo2

now open browser in url bar write localseo.com and hit enter, our local site will load.

1) Improving Site Structure

1.1) Sitemap

Applications need to be well structured based on root/home page, better to using breadcrumbs that help user to navigate root/home page. Sitemap improve crawling of site by crawlers, we can also use a sitemap Xml file to help web crawlers (Google or Other search engine) listing the pages content of the site.

Below is a sample sitemap Xml format, upload the XML file (sitemap.xml) to root folder.

<?xml version="1.0" encoding="UTF-8"?>
<urlset
      xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
      http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">

  <url>
    <loc>http://localseo.com</loc>
  </url>
  <url>
    <loc>http://localseo.com/Home</loc>
  </url>
  <url>
    <loc>http://localseo.com/About</loc>
  </url>
  <url>
    <loc>http://localseo.com/Contact</loc>
  </url>
</urlset>

in iis i have place the sitemap.xml file in root folder.

seo3

2) Dealing with Crawlers

2.1) Web Robots

Web robots are known as spider/crawler are programmed to visit/index the site content automatically. Robots.txt file to give instructions site to web robots.

User-agent: *
Disallow: /

The “User-agent: *” means this section applies to all robots. The “Disallow: /” tells the robot that it should not visit any pages on the site. Learn more about robot.

2.2) Libwww-perl Access BOT

We can restrict BOT access using webconfig by URL rewwrite rules. We need to enable IIS URL Rewrite 2.0. Click Web Platform Installer in IIS Management section.

seo4

a list of component will appear, search with writing “Rewrite” hit enter.

seo6

search result will show  URL Rewrite 2.0, Install it now.

seo5

after installation URL Rewrite icon will appear, double click on it.

seo7

let’s create a new rule for Libwww-perl BOT to restrict access website.

seo8

then configure for BOT rule to restrict.

seo9

or Simply copy paste below code in webconfig then replace ur pattern.

<system.webServer>
  <rewrite>
    <rules>
      <rule name="BOT request BLOCK" stopProcessing="true">
        <match url=".*" />
        <conditions>
          <add input="{HTTP_USER_AGENT}" pattern="^Libwww-perl$" />
        </conditions>
        <action type="CustomResponse" statusCode="403" statusReason="Forbidden: Access is denied." statusDescription="You do not have permission to view this directory or page using the credentials that you supplied." />
      </rule>
    </rules>
  </rewrite>
</system.webServer>

 

3) Server Security

3.1) Server Signature

From security aspects it is important to turn it off, by default it is set on. Here we will rewrite server signature with outbound rule in IIS.

seo10

again double click on URL Rewrite icon and add Server variable like below image.

seo11

seo12

seo13

or Simply copy paste below code in webconfig then replace ur Changed value

<system.webServer>
  <rewrite>
    <outboundRules>
      <rule name="Server Signature">
        <match serverVariable="RESPONSE_SERVER" pattern=".+" />
        <action type="Rewrite" value="Changed" />
      </rule>
    </outboundRules>
  </rewrite>
</system.webServer>

seo14

  4) Canonicalization

4.1) URL Canonicalization

seo16

make sure the bindings are proper with the host name in IIS. Now create a new inbound rule for Canonicalization both IP and URL with www.

seo15

or Simply copy paste below code in webconfig then replace ur pattern and redirect.

<system.webServer>
  <rewrite>
    <rules>
      <rule name="Canonical HOST redirect">
        <match url="(.*)" />
        <conditions>
          <add input="{HTTP_HOST}" pattern="^www\.localseo\.com$" negate="true" />
        </conditions>
        <action type="Redirect" url="http://www.localseo.com/{R:1}" />
      </rule>
    </rules>
  </rewrite>
</system.webServer>

 

5) Optimizing Content

For better performance it is good to cache the static content. There are three different cacheControlMode. The default is NoControl.

  1. NoControl Does not add a Cache-Control or Expires header to the response.
  2. DisableCache Adds a Cache-Control: no-cache header to the response.
  3. UseMaxAge Adds a Cache-Control: max-age=<XXX> header to the response based on the value specified in the CacheControlMaxAge attribute..
  4. UseExpires Adds an Expires: <DATE> header to the response based on the date specified in the httpExpires attribute.

 

5.1) Page Cache (Server Side Caching)

seo19

seo20

<staticContent>
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>

seo21

5.2) Expires Tag

<staticContent>
    <clientCache cacheControlMode="UseExpires" httpExpires="Wed, 01 Jan 2020 00:00:00 GMT" />
</staticContent>

seo22

5.3) HTML Compression/GZIP

seo17

seo18

Finally the webconfig file

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=301880
  -->
<configuration>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <compilation targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" />
  </system.web>
  <system.webServer>
    <staticContent>
      <clientCache cacheControlMode="UseExpires" httpExpires="Wed, 01 Jan 2020 00:00:00 GMT" />
    </staticContent>
    <rewrite>
      <rules>
        <rule name="Canonical HOST redirect">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^www\.localseo\.com$" negate="true" />
          </conditions>
          <action type="Redirect" url="http://www.localseo.com/{R:1}" />
        </rule>
        <rule name="BOT request BLOCK" stopProcessing="true">
          <match url=".*" />
          <conditions>
            <add input="{HTTP_USER_AGENT}" pattern="^Libwww-perl$" />
          </conditions>
          <action type="CustomResponse" statusCode="403" statusReason="Forbidden: Access is denied." statusDescription="You do not have permission to view this directory or page using the credentials that you supplied." />
        </rule>
      </rules>
      <outboundRules>
        <rule name="Server Signature">
          <match serverVariable="RESPONSE_SERVER" pattern=".+" />
          <action type="Rewrite" value="Changed" />
        </rule>
      </outboundRules>
    </rewrite>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>
</configuration>
<!--ProjectGuid: 7D096796-F3E8-4C10-BB3F-2BC4542846C6-->

Hope this will help 🙂

Author:

Since March 2011, have 8+ years of professional experience on software development, currently working as Senior Software Engineer at s3 Innovate Pte Ltd.

2 thoughts on “IIS8 – SEARCH ENGINE OPTIMIZATION(SEO)”

Leave a Reply

Your email address will not be published.