/    Sign up×
Community /Pin to ProfileBookmark

Default Directory Listing File

Hey everyone. I created a script that prints out the current directory on a file server in a nice web interface. On this file server I also have apache running on it. I was wondering if there’s a way to make apache execute this script without having to have a index.php file in every folder on the server since folders get added to this server all the time.

I created a temporary fix by creating a script that would work its way through the server directory, checking every folder to see if this file was in it and if it wasn’t it added the file to the folder. It “works” but it’s still a pain to have to run it atleast once a day.

So, is there something that I can configure in apache to make it look at a single php file instead of having that php file in every folder on the server. (Ex. visiting [url]http://somename/abc/[/url] and visiting [url]http://somename/123/[/url] executes the same script but lists the directory for their respective folder.)

Thanx!

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@bokehAug 02.2006 — You just need a rewrite rule in .htaccess in your root directory that rewrites all requests that end with a "/" to your file.
Copy linkTweet thisAlerts:
@trpt192authorAug 02.2006 — mind enlightening me with a small bit of code to do that? I already have a htaccess file in my root folder but I'm not sure what to put for the rewrite. Thanks.
Copy linkTweet thisAlerts:
@bokehAug 02.2006 — [CODE]RewriteEngine On
RewriteRule ^(|.*/)$ [color=red]yourFile.php[/color]?path=$1 [L][/CODE]
In that file the accessed directory will be available in [I]$_GET['path'][/I].
×

Success!

Help @trpt192 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...