Solved

Apache Redirect/Alias/Default Document?

Posted on 2012-12-27
3
307 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 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