Apache Tutorials and Examples

Command line – top IP list from apache access log

Linux (or Unix) command line utilities like awk, sort, uniq, can be used to analyze apache log to get interesting stats. One use case is read more

PHP – How to log custom data in apache access log

Apache lets you log a specific apache sub process environment variable in access log. PHP lets you set apache sub process env variable using apache_setenv. read more

Apache – how to remove php extension from url

Remove php extension from a specific url To remove php extension from a url (e.g. /foo/bar.php) the following Apache rewrite rule can be used: RewriteRule read more

egrep pipe example on Apache access log

Some egrep pipe examples for Apache access logs on Ubuntu Linux egrep http status code 301 entries $ cat /var/log/apache2/access_log.2015-11-29 | egrep ” 301 ” read more

How to install AWStats on Ubuntu Linux

AWStats is a powerful and featureful tool to analyze apache access logs. Using AWStats, you can view various stats 404, etc. Here are steps to read more

Why and how to log Content-Type in apache access log

It is very handy to log Content-Type in apache access log. It can be used to grep visit of specific content-type (e.g. text/html). Here is read more

Apache – add basic auth to a location or directory

In case you want to protect a directory from public access, you can add Apache basic auth to it. This may be needed if you read more

Disable directory listing in apache

Apache 2.4 on Ubuntu Linux has directory listing enabled by default. In case you are upgrading from apache 2.2 or creating a new site, you read more

Block directory access using htaccess 404

RewriteRule in Apache .htaccess is a convenient way to block directory access to a directory in your Apache document root. This can be useful to read more

prevent wordpress xmlrpc.php attack

Sometimes you may see too many POST requests to xmlrpc.php in your apache access log. Large number of hits to xmlrpc.php can slow down your read more

How to redirect wordpress feed to feedburner feed url

If you have been using wordpress for directly serving rss feed and have recently migrated to feedburner, then some of your users are still being read more

How to set different HTTP Expire Header for multiple images of same type

HTTP expire header can be used to set a expiry time for an image, css or any other content type. The browser does not fetch read more

How to migrate your site from one domain to another

Migrating a site from one domain to another can be a daunting task. But if we create a clear plan then it is a manageable task. read more

ApacheBench (ab) – how to load test a web site

ApacheBench (ab) is a very handy webserver benchmarking tool which can be run from command line. It is extremely simple to use. A quick outcome read more

How to remove urls from Google index using webmaster tools

Many times you want to remove urls from google index. There can be many reasons for doing that. Some of the reasons are: A page read more

How to log page latency and url host in apache log

Apache log can give you lot of insight into the performance of your site. The default configuration of apache does not log the page serving read more

How to handle permanent redirects in wordpress

There are multiple options available to handle redirects in wordpress. A redirect is a way to tell the users and search engines that a page read more

Using python to analyze bots from apache logs

Apache logs contains pretty useful information about various visitors and bots coming to your site. Here is how a typical apache log entry looks like: read more