Welcome to WebmasterWorld Guest from 54.145.246.183

Forum Moderators: Ocean10000 & incrediBILL & phranque

Redirect users from folder browsing

redirect website folders to home page

   
9:55 am on Feb 10, 2008 (gmt 0)

5+ Year Member



I have an HTML web site with many folders. Each folder have many htm pages. I don`t want for some user browse my folders and see list of those pages.
It`s possibel do something to forbid preview all folders and subfolders? I can use redirect module in my cpanel, but it`s irrational - isn`t?
2:08 pm on Feb 10, 2008 (gmt 0)

WebmasterWorld Senior Member encyclo is a WebmasterWorld Top Contributor of All Time 10+ Year Member



You don't need to redirect - assuming your server is running Apache, just add the following to a root-level .htaccess file:

Options -Indexes

Or you can simply add a blank index.html file in each directory.

3:55 pm on Feb 10, 2008 (gmt 0)

5+ Year Member



I tryed to add "Options -Indexes"!
It`s working, but browser show HTTP 403 error!

It`s will be perfect, if it redirect to home page!
Is this possible to do in htaccess?

2:34 pm on Feb 14, 2008 (gmt 0)

10+ Year Member



Try this?


Options -Indexes
ErrorDocument 403 /

I am not sure how efficient this is, but it works for me.

3:28 pm on Feb 14, 2008 (gmt 0)

WebmasterWorld Senior Member wilderness is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



or you may simply add a blank index.html page to the directory.
4:57 pm on Feb 14, 2008 (gmt 0)

5+ Year Member



Try this?
Options -Indexes
ErrorDocument 403 /
I am not sure how efficient this is, but it works for me.

Working, but unproperly!
If you go for example [example324982398.com...]

you will be redirected to frontpage (homepage), but all links on that page will be changed. Let you have page [example324982398.com...] it will be [example324982398.com...]

Why - don`t know!


or you may simply add a blank index.html page to the directory.

Also i must add meta redirection in each page - some work...
5:28 pm on Feb 14, 2008 (gmt 0)

WebmasterWorld Senior Member wilderness is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



I have an HTML web site with many folders. Each folder have many htm pages. I don`t want for some user browse my folders and see list of those pages.
It`s possibel do something to forbid preview all folders and subfolders?

or you may simply add a blank index.html page to the directory.

Also i must add meta redirection in each page - some work...

Not sure why you need any redirection (least of all meta-tag redirects) if your only goal is to prevent directory view of the files?

Do you have some other priorites that you've omitted?

5:47 pm on Feb 14, 2008 (gmt 0)

10+ Year Member



seems like he wants to block access to the folders, plus have a nice looking page show up instead. maybe a normal visitor could accidentally end up at one of those locations some day.

galench, do you have a custom error document that you already use? you could try setting it up to show that page. for example, similar to what craig said:

Options -Indexes
ErrorDocument 403 /your-error-document.html

then, on your-error-document.html, make sure all the images, stylesheets, and javascripts use absolute links instead of relative. like:

bad:
<link rel='stylesheet' type='text/css' href='mystylesheet.css'>

good:
<link rel='stylesheet' type='text/css' href='http://www.mysite.com/mystylesheet.css'>

also good:
<link rel='stylesheet' type='text/css' href='/mystylesheet.css'>

10:42 pm on Feb 14, 2008 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



it is very bad form to use a real page of your site as the error document, especially you root index page. Craft a custom error page for that purpose.
11:59 pm on Feb 14, 2008 (gmt 0)

10+ Year Member



Then try this:


Options -Indexes
ErrorDocument 403 / [R=301,L]

Please note that this is a kludge. You should do a proper page and then redirect from that page if you wish. I have an error.php in my root folder, and I do this:


Options -Indexes
ErrorDocument 404 /error.php?e=404 [L]
ErrorDocument 403 /error.php?e=403 [L]
ErrorDocument 500 /error.php?e=500 [L]

And then, from the error.php page, I give them the ability to search for content, or LINK to the front page. From a design point of view my images and CSS in the error page all link with a "/" in the beginning, e.g., "/images/site.css", so it is relative to the main root folder. This way all the images appear without problems.

Hope this helps.

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month