Solved

Apache Redirect/Alias/Default Document?

Posted on 2012-12-27
3
302 Views
Last Modified: 2012-12-28
We have a website hosted on an Apache server.  (I am completely unfamiliar with the Apache platform, my experience is in IIS)

Our marketing department wants to publish a URL, www.site.com/directory and they want it to automatically pull up www.site.com/directory/testfile.html

In IIS, I'd just set the default document for that directory to the desired file.

I have no idea how to do this in Apache.
0
Comment
Question by:Brodie Krause
3 Comments
 
LVL 1

Accepted Solution

by:
Omar_El_Sergany earned 500 total points
Comment Utility
You need to use DirectoryIndex directive under Apache to set a default page other than index.html or index.php.

The DirectoryIndex directive sets the list of resources or file to look for, when the client requests an index of the directory by specifying a / at the end of a directory name.

Edit httpd.conf

Open your Apache configuration file httpd.conf
# vi httpd.conf

Open in new window


Find out line that read as follows:
DirectoryIndex

Open in new window


Now set it as per your requirements:
DirectoryIndex index.html index.htm default.htm index.php index.pl

Open in new window


Save and close the file. Restart the Apache web server:
# /etc/init.d/httpd restart

Open in new window


Please note that if you do not have access to Apache configuration file. Add DirectoryIndex to your .htaccess file.

You can also specify php or pl dynamic script. Also note that the documents do not need to be relative to the directory. Consider following example
DirectoryIndex index.html index.pl /nav/index.php

Open in new window


Above would cause the php script /nav/index.php to be executed if neither index.html or index.pl existed in a directory.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
You could just change the name of the file to that of the default document.  Wouldn't require you to change anything else.
0
 
LVL 26

Expert Comment

by:arober11
Comment Utility
Or add a symbolic link e.g.

cd /var/www/directory/
ln -s  testfile.html   index.html
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now