Get a list of all virtual hosts which are defined in all apache configuration files

Have you ever looked in the apache config files to see where a website's virtual host is defined? The apache2ctl script has a useful option that could come in good here. When you execute the command, it should look like this: apache2ctl -S You'll obtain a list of all virtual hosts and default servers in ... Read more

How to redirect an HTTP connection to HTTPS in Apache webserver

HTTP to HTTPS

HTTP connections can be redirected to HTTPS using the apache mod_rewrite module. Mod_rewrite should be available in every apache installation. Apache HTTP to HTTPS Redirect Create a file with the name .htaccess in the website root directory which contains the following lines: RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} If you use ISPConfig 3, ... Read more

Redirect a subdomain in Apache and keep the URL in the address bar

Apache Redirect

This tutorial shows you how to use redirect rules in the Apache web server. If you want to redirect a subdomain like sub.domain.tld into a subdirectory of the website and keep the original URL in the browser location bar, you may use the following apache directive. RewriteEngine on RewriteCond %{HTTP_HOST} ^sub.domain.tld [NC] RewriteRule ^/(.*)$ /sub/$1 ... Read more

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

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

How to disable Apache mod_security for a website in ISPConfig 3.

If you use mod_security on your server you might encounter that a website script is not compatible with mod_security. To disable mod_security (v2) for a website, add the following code into the apache directives field: <IfModule mod_security2.c&gt SecRuleEngine Off </IfModule&gt For the older mod_security 1 version, use these configuration directives: <IfModule mod_security.c> SecFilterEngine Off </IfModule> ... 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

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

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