Redirect domains without www (e.g. domain.com) to www.domain.com with apache rewrite rules

Apache www redirect rule

If all your visitors shall access your website with a URL like www.domain.com and not without www, use the following apache rewrite rule for redirecting them. RewriteEngine On RewriteCond %{HTTP_HOST} !^www RewriteRule (.*) http://www.%{HTTP_HOST}$1 [L,R] The apache rewrite rule can be added in a .htaccess file in the website root directory or if you use ... Read more

Enable image caching in apache for better Google Page Speed results

High page speed and short page load times of your website are essential for good search engine rankings today. In this FAQ, I will show you how to enable caching of graphic and CSS files in apache on Ubuntu and Debian. The first step is to enable the expires module in apache: a2enmod headers expires ... Read more

Apache mod_security settings for WordPress and ModX

If you use the apache mod_security module on your apache server, you might encounter wrong 403 errors for several URL's of the cms systems. Here are some exception rules to avoid that: For WordPress Blogs <locationmatch "/wp-admin/admin-ajax.php"> SecRuleRemoveById 300013 SecRuleRemoveById 300015 SecRuleRemoveById 300016 SecRuleRemoveById 300017 </locationmatch> <locationmatch "/wp-admin/page.php"> SecRuleRemoveById 300013 SecRuleRemoveById 300015 SecRuleRemoveById 300016 SecRuleRemoveById ... Read more

Fix “HTTP request length 134926 (so far) exceeds MaxRequestLen” error on Debian Linux

When you get a 500 error in a webpage hosted on Debian Linux (6.0) with apache webserver and fastcgi, take a look into the apache error.log file. This can either be the global error.log or the error.log of the website where you got the error. If you find a error similar to this one: [Fri Apr ... Read more

Apache mod-security installation on Debian 6.0 (squeeze)

Install the apache mod-security 2 module with apt from the Debian repositories apt-get install libapache-mod-security Create the folder for the mod-security configuration files mkdir /etc/apache2/mod-security chmod 600 /etc/apache2/mod-security Download and unpack the mod-security rules cd /tmp wget http://www.modsecurity.org/download/modsecurity-core-rules_2.5-1.6.1.tar.gz tar fvx modsecurity-core-rules_2.5-1.6.1.tar.gz mv *.conf /etc/apache2/mod-security/ ln -s /var/log/apache2 /etc/apache2/logs Configure apache to load the activated mod-security ... Read more

nginx server error: 413 Request Entity Too Large

The nginx webserver has a max. body size limit of 1 MB for requests as default. This might be too low for file uploads in scripts and you will see the following error message when you try to upload a file:  413 Request Entity Too Large The configuration variable for this option is "client_max_body_size" and ... Read more

Webalizer error opening the file /usr/share/GeoIP/GeoIP.dat on Debian Linux

The Webalizer package in Debian 6 has currently small bug as the required package for the  GeoIP database is not installed automatically when Webalizer is installed. The symptoms are that Webalizer statistics was not created and this error message is displayed when Webalizer is run: Error Opening file /usr/share/GeoIP/GeoIP.dat The solution is to install the ... Read more

Redirect http requests to a new folder with apache rewrite rules

When you reorganize the structure of a website, you might want to redirect requests to files in a old folder to a new one without loosing the pagerank. In this example, I will redirect all requests from directory "olddir" to directory "newdir", so that requests like http://www.yourdomain.tld/olddir/page.htm get redirected to http://www.yourdomain.tld/newdir/page.htm without loosing the Google pagerank ... Read more

Prevent DOS attacks on apache webserver for DEBIAN linux with mod_evasive

The following guide explains the installation of the apache module "mod_evasive". Mod_evasive tracks the number of requests of files at the apache webserver and blocks the delivery in case that a certain limit has been reached. Installation apt-get install libapache2-mod-evasive Create the log directory for mod_evasive mkdir -p /var/log/apache2/evasive chown -R www-data:root /var/log/apache2/evasive Now we ... Read more

How to change the language of AWStats statistics on Debian Linux (ISPConfig 3)

To change the language of the website statistics generated by AWStats on a Debian Linux server to e.g. german (de), edit the /etc/awstats/awstats.conf file: nano /etc/awstats/awstats.conf and change the value of the "Lang" variable. To change the languge to e.g. German, cahnge: Lang="auto" to Lang="de" The website statistics are generated nightly on a ISPConfig 3 ... Read more