error_reporting(E_ALL);

ini_set('display_errors', '1');

UPDATE wp_posts SET guid = replace(guid, 'http://www.example.com', 'http://www.new-example.com');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');

exim
exim -bp | grep -i frozen | awk '{print $3}' | while read LINE; do exim -Mt $LINE; done

HTACCESS

#forces ssl, removes trailing slash and removes www
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [NE,R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]

If you need a quick way to reset your public_html data to 755 for directories and 644 for files, then you can use something like this:
cd /home/user/domains/domain.com/public_html
find . -type d -exec chmod 0755 {} \;
find . -type f -exec chmod 0644 {} \;

Scan for hacked files

Run the following command to get the list of all the files containing strings that are longer than 62 alphanumeric characters:
grep -r --include=*.php -e '[[:alnum:]]\{63,\}'
Now to find all the PHP files that contain alphanumeric characters including forward slashes and plus signs that are longer than 136 characters you just need to run the following command:
grep -r --include=*.php -e '[[:alnum:]\/\+]\{137,\}'

apache - htaccess redirect to https://www

RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

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

301 redirect to ssl domain, but allow letsencrypt validation



This is for htaccess and it works
RewriteEngine On
RewriteCond %{REQUEST_URI} !\.well-known/acme-challenge
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]


NOT for htaccess
$servername = gethostbyaddr($_SERVER["REMOTE_ADDR"]);

if(!strpos($servername, "letsencrypt")){
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://dosh4cars.co.uk");
}
else{
echo "<pre>";
print_r($_SERVER["REMOTE_ADDR"]);
print_r($servername);
echo "</pre>";
}