Website optimization - Minimizing Redirects

J Shaw asked on June 29, 2016 04:35

Hi,

I have been running some SEO and website performance tests and one of the complaints is minimizing redirects when the site loads.

http://site.com/ 
https://www.site.com/ 
https://www.site.com/en-us/ 
https://www.site.com/en-us

Does anyone have any suggestions on ways to minimize these redirects, or possibly combine 2 or 3 of the redirects in to one?

Thanks!

John

Recent Answers


Dawid Jachnik answered on June 29, 2016 08:34

Hello,

for the first two you can combine it in the rewrite module. You can setup there any redirect code you want for example 301

This is my quick working example

<rewrite>
  <rules>
    <rule name="CanonicalHostNameRule">
      <match url="(.*)"/>
      <conditions>
        <add input="{HTTP_HOST}" pattern="^www\.yoursitedomain\.pl$" negate="true"/>
      </conditions>
      <action type="Redirect" url="https://www.yoursitedomainpl/{R:1}"/>
    </rule>
    <rule name="Redirect to HTTPS" stopProcessing="true">
      <match url="(.*)"/>
      <conditions>
        <add input="{HTTPS}" pattern="^OFF$"/>
      </conditions>
      <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther"/>
    </rule>
  </rules>
</rewrite>
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.