Setting up a server for SEO optimization

Noor

Administrator
Staff member
1. Home page without duplicates

Usually the home page code is physically located in the file /index.html (or index.php - for most dynamic sites), but the site should open by any of the requests: yoursite.ru, yoursite.ru/index.html , www.yoursite.com and www.yoursite.com/index.html. But for search engines these are four different URLs! If you do not configure .htaccess correctly, the search engine will add four identical pages to its index. This is a sign of a low-quality site. You can avoid this problem using the following code in .htaccess:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.ru
RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ /index\.html\ HTTP/
RewriteRule ^index\.html$ http://www.yoursite.com/ [R=301,L]

All duplicate pages will be merged with a redirect with code 301 (“permanent movement”) with the main page – http://www.yoursite.com/. Before this, of course, you need to check how Yandex indexed the site - with or without www. It is also advisable to assign a matching primary mirror in the robots.txt file.


2. Strict URL of the 404 page

To make sure that the server will display exactly the 404 page that you prepared and created, and not a service or any other page, add the following line:

ErrorDocument 404 http://www.yousite.com/404 .php

Similarly, you can specify pages for other errors.


3. Page and group redirects

You can redirect from one page to another using the Redirect directive:

Redirect 301 /old.html http://www.yoursite.com/new.html

For a group redirect you need to use RedirectMatch - this is a URL and name mask command files.


4. Saving files instead of opening

Many have seen how, when trying to download an archive with a .rar extension, the browser opens it as plain text made up of a jumble of characters. This means that the site server is not configured to force the saving of file types that should not be opened in the browser.

AddType application/octet-stream .rar .doc .mov .avi .pdf .xls .mp4

Other extensions can be added.


5. Setting up CNC (Human Readable URLs)

We strongly recommend using the settings that your CMS provides. Actually, incomprehensible long URLs only appear when using a CMS (they don’t happen on a static site). Therefore, use CMS settings and modules for customization - all modern engines have such capabilities.

For them to work correctly, the .htaccess must contain the line RewriteEngine On (enabling mod_rewrite). Setting up a CNC using bare .htaccess is quite a painstaking task. For example, to turn a URL like www.yoursite.com/script.php?tv=123 into a more understandable www.site.com/samsung/tv/123/, we write these lines (RewriteEngine On should be written if before in .htaccess mod_rewrite has not yet been enabled):

RewriteEngine on
RewriteRule samsung/(.*)/(.*)/$ /script.php?$1=$2

It is clear that to successfully configure the CNC in this way you need to master the entire .htaccess syntax and work hard. It is much easier, we repeat, to use CMS tools.


6. Duplicate pages without a slash at the end of the URL

To prevent the situation with the pages www.yoursite.com/about and www.yoursite.com/about/ being indexed as different, put the following code:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI } !(.*)/$
RewriteRule ^(.*)$ /$1/ [R=301,L]

Pages without a slash will be redirected to “slash” pages.
 
Back
Top