Redirecting From Folders To A Custom Page

Joined: 03/07/2009

Hi Guys,

So, I'm tightening up my site right now and want to stop people browsing folders while allowing the content to still be used on a page.

Example

Say you have at top level a folder ../images which contains all your site images. You want the images to display but don't want people to be able to make changes. Fine set 755 on the folder chmod but... sneaky hacksters poking around can still access the folder typing e.g. mysite.com/images and browse contents, rather than allowing this I want to redirect such requests to a custom "naughty, naughty, naughty!" page whilst still alowing the site to display or use content.

Instinct tells me there's a mod rewrite for this but I need help.

Any advice would be really helpful!

Thanks.

G&G Podcast Host
Matt Farina's picture
Joined: 06/01/2006
.htaccess

Use your .htaccess file to do this. What you want in there is...

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

Matt Farina
Geeks and God Former Co-Host
www.mattfarina.com

Joined: 03/07/2009
That Did It

Hey Matt,

Thanks a bunch, that worked fine!

Appreciate it.

Every blessing,

Pete