Htaccess, redirect and index directory

Published September 27th, 2016
Category Blog, Code, Labs


As an addition to my previous blog post on directory listing, here’s a simpler way to achieve a similar result. / Main difference being not linking your own stylesheet to it, as all the configuration resides in simple .httaccess file/s.

Let’s say you have a domain named allthefiles.com and you want your domain (root directory) to display an index of sub folders and files from allthefiles.com/files. You can create htaccess files that does all the magic required!

 

Redirect domain root to domain sub folder

Make a .htaccess file (copy and paste the code from below) and place it in the folder you want to redirect. For example http://allthefiles.com.

This code example will redirect http:://allthefiles.com to http://allthefiles.com/files

 

Index directory for domain root or domain sub folder

Make a .htaccess file (copy and paste the code from below) and place it in the folder you want to index files and sub folders. For example http://allthefiles.com/files.

This code example will create a index directory for the domain root or domain sub folder you make the .httaccess file.

labs