My .htaccess tricks

Posted on January 14, 2009 by GoogleThem.
Categories: html tips, Web Development 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.(.*)?$ http://domain.com/subfolder/ [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">
<html>
<head>
<title>Your Page Title</title>
<meta http-equiv="REFRESH" content="0;url=http://www.the-domain-you-want-to-redirect-to.com"></HEAD>
<BODY>
Optional page text here.
</BODY>
</HTML>

no comments yet.

Leave a comment

Names and email addresses are required (email addresses aren't displayed), url's are optional.

Comments may contain the following xhtml tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>




Stop SOPA