Solved

Apache Redirect/Alias/Default Document?

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Use System DSN 6 87
Apache Issues 9 80
Nameserver and MX Record 2 71
linux apache localhost dev laptop 5 50
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). #…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

778 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