Noble Dinasaur
Noble Dinasaur

Reputation: 107

How to change a server's index of/ page

When an apache server is running, the http://localhost/~User/ lists the files in the server with a big Index of/ on the page.

I don't know what's the name for this page, but once I put an index.html(or a index.php), the page won't show anymore.

My questions are:

  1. How do I view the listing page with an index file in it?

  2. Is it possible to only show some of the directories/files on the listing page? (If not possible, what is the best practice to redirect?)

  3. How do I disable the listing page, so it's secure for public access?

Upvotes: 0

Views: 477

Answers (2)

ʰᵈˑ
ʰᵈˑ

Reputation: 11375

The manual has all the answers you need.

How do I view the listing page with an index file in it?

You can change the index page so that it won't auto-load the index. DirectoryIndex tmp-index.html See: Directory Listings

Is it possible to only show some of the directories/files on the listing page? (If not possible, what is the best practice to redirect?)

Yes, by using IndexIgnore in your configuration file. See: Excluding files

How do I disable the listing page, so it's secure for public access?

With the Options directive Options -Indexes. See: Directory Listings

Upvotes: 1

Quentin
Quentin

Reputation: 943571

How do I view the listing page with an index file in it?

You don't. mod_autoindex only generates a listing if you don't have an index file.

Is it possible to only show some of the directories/files on the listing page?

Don't turn on ShowForbidden and ensure the files will return FORBIDDEN responses or use the IndexIgnore Directive.

(If not possible, what is the best practice to redirect?)

Probably RedirectMatch, but it depends on exactly what you want to redirect from and to.

How do I disable the listing page, so it's secure for public access?

Put an index file there, or turn off the Indexes Option.

Upvotes: 1

Related Questions