Force all web traffic to redirect to SSL (https) web server using .htaccess file

Here is the minimum amount of configuration needed to force all web traffic (port 80, http) over to https (port 443 via SSL).

1) Create a .htaccess file that looks similar to this one:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*) https://www.example.com/$1 [L]

and place it at the root of the web server directory where you want to redirect the traffic. Restart apache.

2) If that doesn’t work, you might need to modify your apache config file’s AllowOverride setting. If you were trying to use a .htaccess file just inside of the /var/www directory, you might need to edit /etc/apache2/sites-enabled/[name-of-your-site]

...
   <Directory /var/www/>
        ...
        Options FollowSymLinks
        AllowOverride FileInfo
        ...
   </Directory>

NOTE: Your web site might have other directives for Options and AllowOverride, but the 2 that I have show are the bare minimum to get the .htaccess file working.

Make vim “more readable” on black backgrounds

I pretty much live inside of putty/ssh. My defaults are a black background with white/light lettering. However, when I first get to a new system, I find that this is one of the first things that I need to change. Makes reading comments in code sooo much easier.

vim-before-background-dark

So, go ahead and modify /etc/vim/vimrc
[bash]
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark
[/bash]

and remove the ” (double quote) from in front of set background=dark. This uncomments it, and makes that set vcommand visible to vi.

[bash]
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
set background=dark
[/bash]

vim-after-background-dark

Changing the default editor from pico to vim

On new (or new to me systems) I find it annoying to use a program like git, or crontab -e and find myself in the pico editor.  🙁

So, here’s how to change it:

[bash]
sudo update-alternatives –config editor

There are 4 choices for the alternative editor (providing /usr/bin/editor).

Selection Path Priority Status
————————————————————
* 0 /bin/nano 40 auto mode
1 /bin/ed -100 manual mode
2 /bin/nano 40 manual mode
3 /usr/bin/vim.basic 30 manual mode
4 /usr/bin/vim.tiny 10 manual mode

Press enter to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/editor (editor) in manual mode.
[/bash]

and to confirm your selection, run the same command again, and check out the item that has the asterisk next to it:

[bash]
sudo update-alternatives –config editor
There are 4 choices for the alternative editor (providing /usr/bin/editor).

Selection Path Priority Status
————————————————————
0 /bin/nano 40 auto mode
1 /bin/ed -100 manual mode
2 /bin/nano 40 manual mode
* 3 /usr/bin/vim.basic 30 manual mode
4 /usr/bin/vim.tiny 10 manual mode

Press enter to keep the current choice[*], or type selection number:
[/bash]

If that still doesn’t work, try this instead:

[bash]
export EDITOR=/usr/bin/vim.basic
[/bash]

Keeping track of what keeps me on track