Solved

Apache Redirect/Alias/Default Document?

Posted on 2012-12-27
3
304 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
ID: 38725532
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 83

Expert Comment

by:Dave Baldwin
ID: 38725705
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
ID: 38726353
Or add a symbolic link e.g.

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

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

943 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

7 Experts available now in Live!

Get 1:1 Help Now