How to Change the Default Index Page in Apache

How do I change the default index page in Apache?

I recommend using .htaccess. You only need to add:

DirectoryIndex home.php

or whatever page name you want to have for it.

EDIT: basic htaccess tutorial.

1) Create .htaccess file in the directory where you want to change the index file.

  • no extension
  • . in front, to ensure it is a "hidden" file

Enter the line above in there. There will likely be many, many other things you will add to this (AddTypes for webfonts / media files, caching for headers, gzip declaration for compression, etc.), but that one line declares your new "home" page.

2) Set server to allow reading of .htaccess files (may only be needed on your localhost, if your hosting servce defaults to allow it as most do)

Assuming you have access, go to your server's enabled site location. I run a Debian server for development, and the default site setup is at /etc/apache2/sites-available/default for Debian / Ubuntu. Not sure what server you run, but just search for "sites-available" and go into the "default" document. In there you will see an entry for Directory. Modify it to look like this:

<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

Then restart your apache server. Again, not sure about your server, but the command on Debian / Ubuntu is:

sudo service apache2 restart

Technically you only need to reload, but I restart just because I feel safer with a full refresh like that.

Once that is done, your site should be reading from your .htaccess file, and you should have a new default home page! A side note, if you have a sub-directory that runs a site (like an admin section or something) and you want to have a different "home page" for that directory, you can just plop another .htaccess file in that sub-site's root and it will overwrite the declaration in the parent.

How do I change default directory and index file for Apache (installed via XAMPP)

The research link you pasted has the first part of the answer to your question, changing the path you want serve but the second part of your question, making it serve "myFile" as the Index is an additional step. See:

http://httpd.apache.org/docs/2.0/mod/mod_dir.html#directoryindex

So you would add this line inside the relevant tags or even loose in the main httpd.conf file (see the Context section of the above link for valid places to use this directive):

DirectoryIndex myFile.ext

Hope this helps.

Change default page Apache2 Ubuntu

You can use DirectoryIndex directive in vitual host context.

From apache website

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

Here's the example:

<virtualhost *:80>

ServerName domain.com
ServerAlias www.domain.com

# Index file and Document Root (where the public files are located)
DirectoryIndex home.html index.html
DocumentRoot /var/www

</virtualhost>

index.php not loading by default

Apache needs to be configured to recognize index.php as an index file.

The simplest way to accomplish this..

  1. Create a .htaccess file in your web root.

  2. Add the line...

DirectoryIndex index.php

Here is a resource regarding the matter...

http://www.twsc.biz/twsc_hosting_htaccess.php

Edit: I'm assuming apache is configured to allow .htaccess files. If it isn't, you'll have to modify the setting in apache's configuration file (httpd.conf)

Need to change the apache default home page

I think your question is split into 2 things: The ability to use http://vignesh as opposed to http://localhost:8080, and the option to change the default home page.

In order to get the url that you want working, you need to modify a file in windows (assuming you're on windows 7) do the following:

  1. Launch notepad (or any other text editor) with administrative privileges
  2. Open the hosts file located at: C:\Windows\System32\drivers\etc
  3. Add the following entry to it: 127.0.0.1 vignesh

In order to change the default page you need to change the apache configuration.

  1. Open httpd.conf in your favorite text editor
  2. Locate the property called DirectoryIndex. Change it to the page that you want.

I hope that was helpful.

Default index.html page for any virtual host

The solution:

<LocationMatch "^/+$">
Options -Indexes
ErrorDocument 403 /.noindex.html
</LocationMatch>

<Directory /usr/share/httpd/noindex>
AllowOverride None
Require all granted
</Directory>

Alias /.noindex.html /usr/share/httpd/noindex/index.html

How do I set the default page of my website as index.html?

Yes, the DirectoryIndex directive in your Apache configuration must contain (among potential others) index.html

See http://httpd.apache.org/docs/2.2/mod/mod_dir.html

But it's usually the default setting, so make sure your file is actually named index.html and not Index.html, index.HTML or any other case variant because *nix servers are case sensitive.



Related Topics



Leave a reply



Submit