Alternative to index.php using . htaccess

Asked

Viewed 121 times

2

How do I make for the .htaccess put another file, other than index.php, as primary, i.e., put a file called home.php and make it work as if it were a index.php.

I would also like to know some defensive settings that it allows to do about directories.

  • Rodrigo tries for a more suggestive title, "How to define another file as primary?" for example. When the second question tries to be more specific, it becomes too broad.

  • 1

    This question is being discussed at the Meta.

1 answer

6

To change the index.php by another file home.php use that line in your .htaccess

DirectoryIndex home.php

But if you want all the access points to the home.php, only 2 lines in your .htaccess:

RewriteEngine on
RewriteRule . home.php [L]

And not to list files from a directory, add at the beginning of .htaccess that line:

Options -Indexes
  • Thanks for the help.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.