Possible Apache Customizations server-wide

Revert UTF-8 default

If you have ISO-8859-1 content you may need to revert the UTF-8 default. I believe this was introduced in some recent version of Apache and therefore an upgrade can break sites that assume ISO-8859-1 ("latin-1") as default.

vi /etc/httpd/conf/httpd.conf

--> comment out:

# Specify a default charset for all content served; this enables
# interpretation of all content as UTF-8 by default.  To use the
# default browser choice (ISO-8859-1), or to allow the META tags
# in HTML content to override this choice, comment out this
# directive:
#AddDefaultCharset UTF-8

Increase Timeouts

This is to reduce the chance of interruptions in big uploads. (Configuration file path below is the one used by DirectAdmin)

vi /etc/httpd/conf/extra/httpd-default.conf


Timeout 600
KeepAliveTimeout 10


On CentOS 6.4 can be installed with yum (EPEL repository)

yum install mod_xsendfile.x86_64

Otherwise (and specifically for DirectAdmin which uses its own compiled apache):



In .htaccess:

XSendFile On


test script:

header('Content-Disposition: attachment;filename=hello.txt'); 
header('X-Sendfile: /home/username/hello.txt');

Disabled will download empty file

Enabled should download file

If apache does not found the file it will throw a 404 error

Best PHP usage: http://www.brighterlamp.com/2010/10/send-files-faster-better-with-php-mod_xsendfile/

Common Apache adjustments for a new web site

add or remove the www subdomain in URL's

To add it:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

To remove it:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

Taken from: http://www.thesitewizard.com/apache/redirect-domain-www-subdomain.shtml

Redirect any URL to the home page

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/([a-z/]+)$
RewriteRule ^(.*)$ http://lab-esc.com [R,L]

Apache (last edited 2015-03-05 20:17:06 by JaumeSola)