Apache's DocumentRoot directive

22 Jan, 2010

Apache directives
Apache HTTP Server gives you the flexibility to decide where you want to store the web-accessible files for your websites. Most operating systems have their own unique directory structure for their default web server installations, but even those can be changed. The Apache default document root is /usr/local/apache/htdocs.

To change the document root, use the following directive in your httpd.conf or virtual host configuration file:

DocumentRoot directory-path

Replace “directory-path” with the path you want to use. For example:

DocumentRoot /var/www/public_html

Make sure you do not have a trailing slash. With this setup, a file, such as index.html, found in /var/www/public_html/index.html will appear on the web at: http://www.yourdomain.com/index.html. Whatever directory you choose must be readable (but not writable) by outside users.

Source: Apache.org

(0) Comment Categories : VPS & Dedicated, Web Hosting, Web servers
Tag: , , , ,

How to set cookie expiration in Apache

21 Jan, 2010

Apache Software Foundation Logo
Cookies are very important for dynamic websites. They allow you to set parameters for user interaction. With cookies, your website can remember visitors and show them appropriate data, ads, and even specific pages. By default, cookies only last for a single browser session. With the CookieExpires Apache directive, you can set the length of time.

With a dedicated server, you can put the directive into your Apache configuration file, but this is not an ideal setup because it will control cookies for all websites on the server. The better method is to use an .htaccess file for each site.

Add the directive to your .htaccess file or create a new file:

CookieExpires expiry-period

Replace “expiry-period” with the number of seconds (i.e. 432,000 for 5 days) or you can insert as follows:

CookieExpires 2 weeks 3 days 7 hours

Source: Apache.org

(0) Comment Categories : Web Hosting, Web servers
Tag: , , , , ,

Alternative Index Entries

16 Nov, 2009

website url
Question: How do I configure my website to automatically go to a page other than index.***?

Answer: If your web hosting provider is hosting your site using Apache HTTP server, you can accomplish this very easily with an htaccess file. If you do not already have one, create a plain text file in your main web-accessible directory called .htaccess.

Next, use the DirectoryIndex directive followed by filenames you want to include. For example, if your server allows index.html index.htm and index.php but you want index.pl, enter on the first available line in the htaccess file:

DirectoryIndex index.html index.htm index.php index.pl

You can even specify a completely different word like “default.html” or “messageboard.php”. Just one simple line can go a long way in making your site feel the way you want it.

Photo Source: Flickr

(0) Comment Categories : Web Hosting, Web servers
Tag: , , , , ,