How To Force SVG To Use the Correct Content-Type

Author: , April 22nd, 2016

If when trying to use SVG as an image <img src=”image.svg”> or as a CSS background-image, the browser doesn’t display it, your web host is probably serving the SVG with the wrong content-type. Add this to your web server config or .htaccess file: AddType image/svg+xml .svg .svgz

How To Restart Apache Using cron If the Load Gets Too High

Author: , February 3rd, 2016

There are times when the hackers slam my servers and the load gets too high. I use a very simple bash script as a cron job to monitor the load and take action when it gets too high. The script will stop httpd, sleep for a configurable period of time (currently 3 minutes), then start […]

How To Allow Cross-Site Javascript Using Apache

Author: , September 24th, 2015

The key is to send a response header like this: Access-Control-Allow-Origin: * In the Apache web server, one enables this via the following directive: Header set Access-Control-Allow-Origin * This requires the use of mod_headers, which is enabled by default in Apache. For example:

How To Auto-Restart Apache If the Load Gets Too High

Author: , September 15th, 2015

The script to check and restart apache…works on CentOS – YMMV!

Add to cron * * * * * /root/restart_apache_if_load_hits_threshold.sh >> /var/log/restart_apache_if_load_hits_threshold.log 2>&1

How To Use Apache Scalp Log Analyzer to Catch Website Attacks

Author: , August 31st, 2015

Requires Python! Scalp Home https://code.google.com/p/apache-scalp/ Download Scalp: https://code.google.com/p/apache-scalp/downloads/detail?name=scalp-0.4.py Backup Link: http://www.wyzaerd.com/scalp/scalp-0.4.py Original (Broken) XML Rules File: https://dev.itratos.de/projects/php-ids/repository/raw/trunk/lib/IDS/default_filter.xml Fixed XML Rules File: http://www.wyzaerd.com/scalp/default_filter.xml To Fix the XML file: Replace: (?:all|distinct|[(!@]*)? with (?:all|distinct|[(!@]+)? and: (?i:(\%SYSTEMROOT\%)) with (?:(\%[sS][yY][sS][tT][eE][mM][rR][oO][oO][tT]\%)) Examples:

Current options: exhaustive: Won’t stop at the first pattern matched, but will test all the patterns tough: Will […]

How to Install Apache mod_evasive on AWS Linux/CentOS

Author: , July 26th, 2014

I was getting tired of using iptables to block the various hackers and bots constantly slamming my servers (the Chinese are the worst offenders by far – curse them!). I found the Apache module mod_evasive and installed it. Here are links to various articles about mod_evasive: http://www.zdziarski.com/blog/?page_id=442 https://coderwall.com/p/eouy3g http://www.crucialp.com/resources/tutorials/server-administration/flood-protection-dos-ddos-protection-apache-1.3-2.0-mod_dosevasive-avoiding-denial-of-service-attacks.php Add the Module to Apache I […]

How To Protect a Single File in Apache

Author: , June 30th, 2013

In order to protect a file, just replace the Directory directive with Files:

How To Find the Complete Page URL in PHP

Author: , October 25th, 2012

How To Fix SUEXEC Warnings After Yum Update On AWS Linux

Author: , March 3rd, 2012

After a recent yum update I started getting the following errors when starting Apache: Warning: SuexecUserGroup directive requires SUEXEC wrapper. It turns out that the permissions for suexec need to be reset: chmod 4111 /usr/sbin/suexec

How To Make SEO-Friendly URLs Using Apache mod_rewrite And PHP

Author: , December 15th, 2011

Below information copied without permission from Josh Sharp’s site because it is too valuable to lose – great work Josh, and THANKS!

Note: Only rewrite if the requested file is not an existing directory (-d) or a file (-f)