Servers

WordPress and ModSec using the OWASP Rule Set

Running WordPress and Mod Security together can be a challenge but we have been doing it successfully for a few years now so I thought I’d share our Global Disable list and User configuration settings. These rules are globally disabled in /usr/local/apache/conf/modsec2.whitelist.conf: 981261 950901 981244 981243 981248 981257 960015 958979 981245 973343 950109 981249 973336…

Read More

Migrate Multiple Domains to New Domain Using .htaccess

Ok so you have multiple domains all pointing to your main domain where your site lives. But now you want to change the main domain, so you need to redirect all requests, for all the alias domains, to the new main domain and generate a 301 response so search engines and browsers know that the…

Read More

cPanel Email Error: "retry time not reached for any host after a long failure period"

This can be caused by a corrupt database file. Fix it by running the following SSH commands as root: cd /var/spool/exim/db rm -f retry retry.lockfile rm -f wait-remote_smtp wait-remote_smtp.lockfile service exim restart or /usr/sbin/exim_tidydb -t 1d /var/spool/exim retry > /dev/null /usr/sbin/exim_tidydb -t 1d /var/spool/exim reject > /dev/null /usr/sbin/exim_tidydb -t 1d /var/spool/exim wait-remote_smtp > /dev/null /scripts/courierup…

Read More

Simple Down for Maintenance Page using .htaccess

.htaccess To put a site into maintenance mode put either of the following in an .htaccess file in the site root. 1) Very simple #close the site down ############################################ RewriteEngine On ErrorDocument 403 /maintenance.php order deny,allow deny from all allow from xxx.xxx.xx.xxx #end of closed site rules################################## The “allow from” line permits access only from…

Read More

SSH commands to remember

A list of SSH commands that I use most and should remember. Feel free to add your own via the comments section. List disc usage in readable format sorted by size du -hs * | sort -h Find the path to the loaded php.ini file php -i | grep php.ini Show uptime and load averages…

Read More

Specifying IP range using slash notation (CIDR Notation)

This is useful when specifying a range of IP addresses to block for instance. Full details here: http://networkengineering.stackexchange.com/questions/3697/the-slash-after-an-ip-address-cidr-notation Quick and nasty explanation: The number after the slash specifies the subnet mask to use which in turn limits the wild card numbers in the IP address IP Address Subnet Mask IP Range 192.168.10.0/24 255.255.255.0 192.168.10.* 192.168.10.0/16…

Read More

htaccess Redirect and Remove Query String

To redirect menu.php?diet=vegan to /new-page-name whilst loosing the query string use this redirect in the .htaccess file RewriteRule ^menu\.php$ /new-page-name? [L,R=301]  The trailing ? removes the query string

Read More

Running WordPress with Tilde (~) in Site URL

For example to run WordPress on a URL such as:http://www.babelscribe.com/~mysite/ Change siteurl and blogname in the options table to the above url. Change default htaccess redirects to: RewriteEngine On RewriteBase /~mysite/ RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /~mysite/index.php [L] This is useful if you need to access an account…

Read More

Redirect Parked Domain to Main Domain

In .htaccess to redirect the .com to the .co.nz with and without the www # redirect the parked .com to .co.nz RewriteCond %{HTTP_HOST} ^parkeddomain.com$ [NC,OR] RewriteCond %{HTTP_HOST} ^www.parkeddomain.com$ [NC] RewriteRule ^(.*) http://maindomain.co.nz/$1 [R=301,L]

Read More

Parse PHP within HTML file

To make the server parse php within an html file, add this to the .htaccess file AddType application/x-httpd-php .php .htm .html or AddType application/x-httpd-php5 .html Check with your host for correct format.

Read More