Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use .htaccess to make custom Index Of pages? If so how?

You know how when you go to a url on a server and the directory doesn't have an index.* file or a default.* file it shows you a list of the directorie's contents? I was wondering if there is any way to customize the way that index looks or theme it to fit your site. For instance I'd want to add the php

<?
include 'template.php';

head();
?>

Before the listing. And

<?php
foot();
?>

After. Can this be done?

like image 390
watzon Avatar asked Sep 16 '25 06:09

watzon


2 Answers

I have never done this before, but this shows how to do it: http://www.webmasterworld.com/apache/3589651.htm via .htaccess.

Edit: Maybe this (snapshot) shows exactly what you want, it's a walk-through of how to embed header and footer in the listing page.

like image 125
M. Suleiman Avatar answered Sep 17 '25 19:09

M. Suleiman


Sure, you can add your own DirectoryIndex file which can even be PHP.

In you .htaccess file:

DirectoryIndex my-dir-listing.php

Do inside the my-dir-listing.php file whatever you need to do the directory listing.

If you want to modify the header of the existing listing, take a look into the HeaderName directive.

like image 41
hakre Avatar answered Sep 17 '25 19:09

hakre