User Guide - Apache Web Server Modifications


Applicable Plans - All eApps General VPS Plans

User Guide - Apache Web Server Modifications

Overview

There are many configuration options for the Apache web server, ranging from htaccess file to rewrite directives. Technically speaking, all of them are considered server modifications, and are not supported by eApps.

If you are making these types of modifications to the web server, you will need to familiarize yourself with the concepts and usage for these technologies, and know how to find answers and how to troubleshoot problems if things do not work as expected.


However, whenever possible we will try to assist you if you have a problem with a particular server modification, with the understanding that any assistance from eApps support could be considered billable at our standard rate of $15 per 10 minutes.

This User Guide is a quick overview on making basic modifications to the Apache web server. For more information on managing the Apache web server and your sites, see the following User Guides:
Note This User Guide is for managing sites using the Apache web server, not an application server like Tomcat, JBoss, Ruby on Rails, or GlassFish. For information on troubleshooting sites using those application servers, see their specific User Guides - http://support.eapps.com/kb


Most possible server modifications, such as htacess files or mod_rewrite directives, are documented extensively online. As the site maintainer and owner, it is your responsibility to be familiar with the methods you are using to add functionality to your site.

Common Server Modifications
Changing the site DocumentRoot
Changing the DirectoryIndex file for a site
Redirecting the web site to another URL (301 redirect and mod_rewrite)
Redirecting an entire site to another URL (either on or off the VPS)
Redirecting the request for a specific file (usually a page) to another file (another page or an updated page)
Redirecting all non-www traffic to www
Redirecting all http traffic to https
Include files
Default Character Set (CharSet)
ProxyRequests

eApps Support Guidelines

Links to other information


Common Server Modifications

Some of the more common server modifications are changing the DocumentRoot, changing the DirectoryIndex file, and redirecting a web site to another URL. Forcing a site visitor to use a specific URL or to use https are also common server modifications.

Changing the site DocumentRoot

The DocumentRoot is the directory (folder) where the content for the web site is served from. By default, it is located at /home/webadmin/eapps-example.com/html - meaning that the site index files are in the /html directory, and all other content is served relative to that path.

This means that when you go to http://www.eapps-example.com in your browser, the web server reads that request, and serves the files for the site starting at /home/webadmin/eapps-example.com/html.

To see the DocumentRoot for a site, look at Website Settings for that site - the DocumentRoot is listed under the General Settings tab.


There are times when the DocumentRoot needs to be changed. For example, if you are running a Wordpress or Joomla site, the applications are installed by default to /home/webadmin/eapps-example.com/html/wordpress or /home/webadmin/eapps-example.com/html/joomla. This means that your blog's URL would be http://www.eapps-example.com/wordpress or http://www.eapps-example.com /joomla.

This is fine if the blog is just a part of the main eapps-example.com site, but if the blog is the site, then the DocumentRoot can be changed so that the web server looks in the /wordpress or /joomla directories for the site index files.


To change the DocumentRoot, go to the Site Tab for the site in question, Website Settings, Custom Settings tab. Click on Edit, and add this line (changing the path to match your exact domain and location):

DocumentRoot   /home/webadmin/eapps-example.com/html/wordpress

(note that there is NO trailing slash after wordpress)

Once the change has been made, click Update to save the changes - this will also restart the web server. Now, going to http://www.eapps-example.com will bring up the Wordpress blog, instead of the content located in the /html directory. This is also covered in the User Guides for Wordpress and Joomla and Drupal.

Changing the DirectoryIndex file for a site

The DirectoryIndex is the list of resources to look for when a client requests the index of a directory. What this means is that when the browser goes to http://www.eapps-example.com/ the web server reads the DocumentRoot for that site, and looks in /home/webadmin/eapps-example.com/html (or where ever the DocumentRoot is set to) for a file that serves as the index file for the site. Traditionally, this is index.html, but it can be other files instead.

The default DirectoryIndex for the Apache web server is:

DirectoryIndex index.html index.shtml index.html.var

If you are trying to use an index.htm or index.php file (to use two examples), the web server will not recognize that those files are to be used as the DirectoryIndex for your site, and will either display the default eApps Welcome page, or the Apache Web Server page that is shown whenever no DirectoryIndex can be found.

To change the DirectoryIndex, go to the Site Tab for the site in question, Website Settings, Custom Settings tab. Click on Edit, and add this line (substituting the actual DirectoryIndex file you wish to use):

DirectoryIndex index.htm

Once the change has been made, click Update to save the changes - this will also restart the web server. Now, going to http://www.eapps-example.com will use the correct DirectoryIndex file you specified.

Note This only makes the DirectoryIndex change for this specific site. If you need to have the same index.htm file as a DirectoryIndex for all sites, you will need to add the same line in Custom Settings for all sites that use the index.htm file.

Redirecting the web site to another URL (301 redirect and mod_rewrite)

For various reasons, you may need to redirect traffic from your existing web site to an external site, or to different pages on your actual site. This is often done to preserve SEO rankings in search engines.

The way to do this is with a 301 redirect. There are many examples online for how to implement a 301 redirect, and not all of the various methods can be covered in this User Guide. If the examples given do not meet your needs, a quick web search will turn up page after page of information.

For the 301 redirect, a .htaccess file is used. The file, which is named .htaccess (dot htaccess - note the period at the beginning of the file name) must be placed in the DocumentRoot of your web site, and be owner and group of the owner of the web site files.

Warning The syntax for a .htaccess file has to be exactly right. There is no middle ground or room for error. Your syntax is either absolutely correct, or totally wrong. One misplaced or forgotten slash, or a space where a space shouldn't be can mean that you may now be totally unable to browse the site, or that your .htaccess file is completely ignored.

Due to the complexity of the directives that can go in a .htaccess, any assistance from eApps support to configure or troubleshoot your custom .htaccess file could be considered billable support, at our standard rate of $15 per 10 minute increment. A .htaccess file is considered a server modification, and is your responsibility to setup, test and troubleshoot. The Links to other information section has links to more .htaccess and mod_rewrite information.

Redirecting an entire site to another URL (either on or off the VPS):

redirect 301 / http://www.othersite.com

This will take a request for http://www.eapps-example.com and redirect that to http://www.othersite.com

Redirecting the request for a specific file (usually a page) to another file (another page or an updated page):

redirect 301 /index.html http://www.eapps-example.com/newindex.html

This will take the request for http://www.eapps-example.com (with an index page of index.html) and redirect that to http://www.eapps-example.com/newindex.html

Redirecting all non-www traffic to www

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

This will take any request for http://eapps-example.com and rewrite it to http://www.eapps-example.com
This can also be done from the Custom Settings tab for the site.

Redirecting all http traffic to https

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.eapps-example.com/$1 [R,L]

This will take any request for http://www.eapps-example.com or http://eapps-example.com on port 80and redirect it to https://www.eapps-example.com. This is used when you want all visitors to use the SSL site, even if they entered the URL as http instead of https.
This can also be done from the Custom Settings tab for the site.


 

Include files

If you need to include a lot of server customization, you can create an Include file for the site that contains all your mod_rewrite and redirect rules.

Any valid directive for a virtual host block can go inside an Include file. Name the file with something relevant to your site, such as eapps-example_site.conf, and place that file in the /etc/httpd/conf.d directory.


Then, in the Custom Settings for that site, add this line:

Include /etc/httpd/conf.d/eapps-example_site.conf

Click on Save to update and restart Apache, and now the Include file will be read every time the web server restarts. This is useful for sites that have a large number of directives, as it is easier to edit and manage a separate file than to have to use the Control Panel, which can be slow for large files.

If you ever migrate to a new VPS, it is also easier to move an Include file than it is to remember and copy and paste all the settings in Custom Settings for the site.


 

Default Character Set (CharSet)

The Default Character set is the one of the only supported modifications to httpd.conf (the other being the MaxClients/ServerLimit parameters).

The default character set is the name of the character encoding to be added to a response if the content type if text/plain or text/html. See the official Apache documentation for your version of Apache for a more detailed explanation - http://httpd.apache.org/docs


By default, the CharSet is UTF-8. However, this can be changed if needed to match the character encoding for your language.

[root@eapps-example ~]# cd /etc/httpd/conf
[root@eapps-example conf]# cp httpd.conf{,.bck}
[root@eapps-example conf]# vi httpd.conf

Look for this section:

# 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

Change the UTF-8 parameter to match the encoding you wish to use for your language, and save and exit the file. Restart the web server for this change to take effect.

Note these lines from the comments: 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 - this means that you can use information in your sites META tags to also set the Character Set for the pages. The W3C recommendation is here - http://www.w3.org/TR/REC-html40/charset.html

A list of character sets can be found here - http://www.w3.org/International/O-charset-lang.html. Be aware that this list is deprecated, because the W3C now specifies UTF-8 instead of any of the language specific character encodings.


ProxyRequests

In the Apache httpd.conf file, proxy requests are set to off - ProxyRequests Off
If you change this to On, you run the risk of your VPS being used by outsiders to proxy all their web traffic. Leave this value to Off.


eApps Support Guidelines

eApps Web Hosting is responsible for the Apache Web Server as installed in your VPS. It is our responsibility to ensure that Apache is installed correctly, and that the default Welcome Page shows correctly in a browser. We use a standard install of the latest version of the Apache server that was available to us from Parallels when the VPS was created. If you are using PHP for your sites, it is our responsibility to ensure that PHP is installed correctly and functioning.

eApps Web Hosting is not responsible for your sites, or the content of your sites, or the functionality of your sites. If the Apache Web Server is running, and the default Welcome Page shows for a new or default site, then that is technically the extent of our responsibilities.

If your sites have mission or business critical data or configurations, it is your responsibility to make sure that the content for the sites is safely backed up. Do not rely on eApps to have current copies of your data or files.

Any server modifications, such as htaccess files or mod_rewrite directives, are outside of our support boundaries. It is assumed that if you are making these types of modifications to your web site that you are familiar with the setup, configuration, and troubleshooting for these types of modifications, or that you know where to search to find the answers. Any assistance with server customizations such as htaccess files or mod_rewrite, or any assistance troubleshooting your site content or functionality could be considered billable support, at our standard rate of $15 per 10 minute increment.

If you make manual changes to httpd.conf, or add modules or make any other configurations changes to the web server, be aware that any support needed to correct problems caused by these modifications will be billable, at our standard rate of $15 per 10 minutes.

If you have made manual, unsupported changes to httpd.conf or to any other part of the web server and are requesting eApps Support assistance, please let us know, as this could save valuable time troubleshooting the problem.

The general assumption, if you are making unsupported changes to httpd.conf or to the web server, is that you are an expert in Apache web server configuration, and will not require any support assistance from eApps if you encounter any problems.

All changes to the virtual host blocks in httpd.conf must be done from the Control Panel. If you manually edit the virtual hosts in httpd.conf, the Control Panel will overwrite your changes, and your sites may stop functioning. This is a feature, not a bug, and this behavior cannot be changed.

As always, eApps support will go the extra mile to assist you with any problems you may have with your websites, but with the understanding that the content and functionality of your sites is ultimately your responsibility.


Links to other information

htaccess techniques - http://www.noupe.com/php/htaccess-techniques.html
mod_rewrite - http://www.addedbytes.com/apache/mod_rewrite-cheat-sheet/
robots.txt information - http://www.robotstxt.org/

Google 301 redirects information - http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=93633
Official Apache .htaccess tutorial - http://httpd.apache.org/docs/2.0/howto/htaccess.html
Official Apache mod_rewrite guide - http://httpd.apache.org/docs/2.0/misc/rewriteguide.html


Comments

Please login to comment