Pilot article!
This article is a pilot! This means that the quality of the content may be low...

Do not judge strictly! A journey of a thousand miles starts with first step!

Implementing a versioning of a static site through .htaccess may interest those who use hosting services. There are few options for configuring the server and this is one of them.

It consists of the following:

  1. At the root of the site we put the folder with the name of the version, for example 1.0.26!
    At the root of the site we put the folder with the name of the version, for example <code>1.0.26</code>.
  2. Also, put the .htaccess file in the root of the site, with the following directives:
    RewriteCond %{REQUEST_URI} !^/1.0.26/
    RewriteRule ^(.*)$ /1.0.26/$1 [L]
    Also, put the <code>.htaccess</code> file in the root of the site, with the following directives.

Now the Apache server will redirect all requests without the version number to the specified folder, that is, 1.0.26.

This configuration makes it easy to release new versions, or, if something went wrong, roll back to the previous stable version. It's enough just to change the version in the .htaccess file.

Nuances:
  • All pages will have a duplicate URL: /some/page/url and /1.0.26/some/page/url. For search engines, you need to specify a "canonical page" on all pages:
    <link rel="canonical" href="https://vadimfedorov.ru/some/page/url/" />
  • If you have access to the server, it's probably easier to organize this kind of versioning through "symlinks". Picked up the theme on Stack Overflow.
Best articles
Programming