Kompx.com or Compmiscellanea.com

HTTP to HTTPS redirect in .htaccess

Web servers : Apache + nginx

Redirecting from HTTP to HTTPS, when the web server serving the pages is behind a load balancer or reverse proxy. Server configuration:

  • Apache + nginx;
  • SSL is enabled;
  • SSL-certificate is purchased, approved and installed.

That is, everything is up and running. So it is just the HTTP to HTTPS redirection that is left to get ready and start up. Directives for .htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\. [NC]

RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{HTTP:X_FORWARDED_PROTO} !https [NC]

RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

HTTP to HTTPS redirect

-- Enable runtime rewriting engine:

RewriteEngine On

-- If domain name has no www:

RewriteCond %{HTTP_HOST} !^www\. [NC]

-- Then replace it with domain with www:

RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

-- If HTTPS is not present:

RewriteCond %{HTTP:X_FORWARDED_PROTO} !https [NC]

-- Then replace domain without HTTPS with domain with HTTPS:

RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

Notes

1. X_FORWARDED_PROTO may instead be called X-Forwarded-Proto or even else. The point is to obtain the information from a load balancer or reverse proxy on the original request it gets. Load balancers or reverse proxies may provide the web server with this info and a header named X_FORWARDED_PROTO or X-Forwarded-Proto or else may be sent, holding the protocol string. It is most often so, but not always. So it should probably be determined by practice how to get the protocol string in a particular case.

2. The other way is just to set the environment variable (if it is suitable for the given web server):

SetEnvIf X_FORWARDED_PROTO https HTTPS=on

Then directives for .htaccess file are to be like this:

RewriteEngine On

SetEnvIf X_FORWARDED_PROTO https HTTPS=on

RewriteCond %{HTTP_HOST} !^www\. [NC]

RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{HTTP:HTTPS} !on [NV]

RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

3. Apache Module mod_rewrite docs: http://httpd.apache.org/docs/current/mod/mod_rewrite.html


Aliosque subditos et thema

 

Windows console applications

 

Some time ago text-based applications were the only form of software of average end user computer experience. As well as after the graphical user interface programs started to become widespread, console applications used to retain their strong positions. But gradually GUI software virtually superseded text-based applications in daily use of the average end user. However, even now there are console programs that can more or less compete with software of graphical user interface, be useful for the average user to solve various problems and fulfill numerous tasks on modern computers. Windows console applications. File managers Windows console applications. Multimedia Windows console applications. Web browsers Windows console applications. Text editors Besides file managers, multimedia programs, text editors, web browsers, there are plenty of other text-based programs and utilities for use under Windows: both standalone and those included in MS Windows distributions. For example, ipconfig and netstat for work with network, Windows built-in FTP client useful for some tasks, CommandBurner for command line burning CD / DVD or cdburn with dvdburn from Windows Server 2003 Support Tools for the same, etc.

Extract tar.bz2

 

Extracting tar.bz2 files in Linux, command line: tar jxvf file.tar.bz2 - j : filter the archive through bzip2 [ 1 ] - x : extract files from an archive - v : list the files processed - f : use archive file The command extracts the contents of a bzip2 compressed archive to the current directory. Tar creates an archive of one or several files. Then bzip2 is used to compress it. Or both processes are made at once by tar only, with corresponding options employed. The duality of nature - archived and then compressed - is reflected in the extension of the file ("tar.bz2") and requires two procedures to be performed while extracting: decompressing and unpacking. Hence both j (decompress it) and x (unpack it) in the command. [ 1 ] Sources for the option letters description: tar(1) - Linux man page and LinuxCommand.org