Drupal Dump

Drupal Snippets, Hacks and more....

Properly setup redirects from www to non-www on nginx

In many online tutorials you will find just few lines like 

server {
    server_name www.example.com;
    return 301 $scheme://example.com$request_uri;
}

but actually you need much more, you need to include SSL certificates, otherwise you will get message about insecure site so you should have this

Auto indent lines with vim

Type this to auto format a messed up file when editing with VIM

So, gg to get the start of the file, = to indent, G to the end of the file, gg=G.

Change FQDN on server

You'll want to edit /etc/hostname with your new hostname, so just go and change it and then update your /etc/hosts with

127.0.0.1 localhost
1.2.3.4 your-new-hostname