Remove trailing slash with Apache

With Apache and mod_rewrite, to avoid urls like /page1 and /page1/ to respond with the same content, you can use mod_rewrite with the following syntax: # Remove trailing slash RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]

 

Permanent redirect with Apache and mod_rewrite

Redirect old url to a new url RewriteEngine On RewriteRule /oldurl /newurl [R=301,L] Canonical domain rewriting RewriteEngine On RewriteCond %{HTTP_HOST} ^domain\.com$ [NC] RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]   See also Apache module mod_rewrite documentation Permanent redirect with nginx Permanent redirect with lighttpd  

 

Rotate Apache logs with Cronolog

Cronolog is log rotation program which gives you a lot of options to template the log destination files. The common use is to split logs by year / month / day. Here is how to configure Apache to send log entries to cronolog : CustomLog “|/usr/sbin/cronolog /home/log/apache2/%Y-%m-%d_domain.com_access.log” combined This will create a log file named …