My .htaccess tricks

To show a directory listing specifically in that directory only place this in the .htaccess file that resides in that folder:

IndexOptions -FancyIndexing
 Options +Indexes

To deny a directory listing, place this the the .htaccess in that directory or in a higher directory:

 Options -Indexes

Now a 403 error will be returned instead.

To redirect to a subdirectory or a folder:

RewriteEngine On
RewriteBase /
RewriteRule ^index.(.*)?$ [r=301]

This will redirect any attempt to access a file named index.something to your subfolder, whether the file exists or not.

A simple HTML redirect is an alternative:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<title>Your Page Title</title>
<meta http-equiv="REFRESH" content="0;url="></HEAD>
Optional page text here.

Leave a comment