Probably Your heard about ‘duplicate content’ and that it can destroy all of your SEO work. And having site versions with ‘www’ and without it and not redirecting them properly is recognized as ‘duplicate content’.

When You weren’t responsible for this part of web development (and don’t really know what going on here) type domain.com, www.domain.com and www.domain.com/index.html in your browser (or another index file type like index.php) and see what happens. If You always see single site version, for example without ‘www’ prefix it’s just good (by the way redirecting all site versions to version without ‘www’ is better idea from SEO perspective).

If no, we have some work here.

First how to remove index.html

1

2

3

4

5

6

7

# Removes index.html from ExpressionEngine URLs

RewriteCond%{THE_REQUEST}^GET.*index\.html[NC]

RewriteCond%{REQUEST_URI}!/public_html/.*[NC]

RewriteRule(.*?)index\.html/*(.*)/$1$2[R=301,NE,L]

If You have index.php – just change index\.html to index\.php

And now – redirecting from www to to withot www version:

1

2

3

4

5

# Directs from www to without www

RewriteCond%{HTTP_HOST}^www.domain.com(.*)[NC]

RewriteRule^(.*)$http://domain.com/$1 [R=301,L]

301 redirections

301 redirections are commonly used to ‘tell search engine’, that we have permamently moved our site to new location. 301 redirection gives almost 100% link-juice from old domain to the new one and in most instances it’s the best method for implementing redirects on a website.

When we want to redirect traffic from /category/television/ to /category/tv/ we should put code like below in our .htaccess:

1

Redirect301/category/television/http://www.example.com/category/tv/

Caching

Caching is very important to SEO nowadays. Page speed is one of main factors, used by Google to determine sites position. When we have already prepared Our website and don’t plan dramatic changes in its look in the near future, then we can ‘tell Google’ to have some site elements stored longer in users browser cache. In this way, when someone visits site second time, it’s loaded much faster!

Here’s some nice working piece of code for You. When You use WordPress just past it in You .htaccess before ‘Begin WordPress’. When using different platform or build site without any CMS platform take elements, which suits Your needs (images).

We can see, if it works and speeds our site up using Google Speed Insights. Tell me how Your score have changed in few minutes

Excluding traffic (bot) – ban certain IP addresses

Sometimes server is overloaded with tons of bot requests. We see, that our site is loading longer (for example in Google Search Console, in mentioned Google Speed Insights or when analyzing stats directly on server site), then it can be because of large amount of bot traffic.

Using .htaccess we can exclude traffic from specific IP addresses (responsible for bot traffic):

1

2

3

4

5

6

7

8

9

<Limit GET POST>

order allow,deny

deny from xxx.xxx.xx.x

allow from all

</Limit>

Last thing – very important.Protect Your .htaccess

1

2

3

4

5

6

7

8

9

<files~"^.*\.([Hh][Tt][Aa])">

order allow,deny

deny from all

satisfy all

</files>

And how to generate .htaccess file. You can do it easily using standard Notepad available in Windows. Just choose “save as” option, then choose file format “all files” (not .txt) and name file “.htaccess”. That’s all!

That’s all for my first post. I would be very gratefull, if have helped anyone! If You have any questions or just want to share opinions, discuss this topic/or also want to discuss different ones – feel free to do it.