Solved

Apache Redirect/Alias/Default Document?

Posted on 2012-12-27
3
308 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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