SSH : Change Owner of files and folders

Change Owner of All files within a Folder

Here is how to change Owner of Files and Folders in SSH as a Bulk

  • Login to SSH
  • Run
    chown -R user:usergroup /location/of/the/folder/*

Change Owner of one file

chown user:usergroup /location/of/the/folder/file-name.php

Find the list of files under a Owner

find /location/of/the/folder/ -user USERNAME

Permanent 301 Redirect Setup in .htaccess

Redirect old domain to new domain

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.org/$1 [L,R=301,NC]

Force Redirect to NON-www version

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301,NC]

Force Redirect to WWW version

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]

Redirect from HTTPS to HTTP

RewriteEngine on
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Redirect from HTTP to HTTPS

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Redirect files with certain extension

RewriteEngine On
RewriteCond %{REQUEST_URI} .aspx$
RewriteRule ^(.*).php$ /$1.php [R=301,L]

Redirect Individual Files

Considering Two Situations

  1. Redirecting File within the same domain
  2. Redirect File to Another Domain

Redirect File with

Redirect old domain to new domain

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.org/$1 [L,R=301,NC]

Force Redirect to NON-www version

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301,NC]

Force Redirect to WWW version

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]

Redirect from HTTPS to HTTP

RewriteEngine on
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Redirect from HTTP to HTTPS

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Redirect files with certain extension

RewriteEngine On
RewriteCond %{REQUEST_URI} .aspx$
RewriteRule ^(.*).php$ /$1.php [R=301,L]

Redirect Individual Files

Considering Two Situations

  1. Redirecting File within the same domain
  2. Redirect File to Another Domain

Redirect File within the Same Domain

Redirect 301 /file1.htm /file2.htm

Redirect File to Another Domain

Redirect 301 /file1.php http://example.org/file2.php

in the Same Domain

Redirect 301 /file1.htm /file2.htm

Redirect File to Another Domain

Redirect 301 /file1.php http://example.org/file2.php