homepage Welcome to WebmasterWorld Guest from 54.234.147.84
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Redirect users from folder browsing
redirect website folders to home page
galench




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

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?

 

encyclo




msg:3570891
 2:08 pm on Feb 10, 2008 (gmt 0)

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.

galench




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

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?

craig1972




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

Try this?


Options -Indexes
ErrorDocument 403 /

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

wilderness




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

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

galench




msg:3575015
 4:57 pm on Feb 14, 2008 (gmt 0)

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...

wilderness




msg:3575046
 5:28 pm on Feb 14, 2008 (gmt 0)

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?

Mike521




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

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'>

g1smd




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

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.

craig1972




msg:3575303
 11:59 pm on Feb 14, 2008 (gmt 0)

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved