Forum Moderators: phranque

Message Too Old, No Replies

How to ban access to directory, but not files within

         

Harry

2:41 pm on Jan 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello. How do I protect a directory, say "/widget/" but not a file which should be accessible by visitors like /widget/about

I don't want visitors looking at some of the files in the directory as they are scripts and other important files that enable the /widget/about/ page to work properly. I cannot put the about/ page in another directory.

Thanks

IanTurner

2:57 pm on Jan 5, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Which server are you using?

Harry

3:11 pm on Jan 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I must be apache since it has htp access. I know it's not Microsoft but Unix.

IanTurner

3:16 pm on Jan 5, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Sorry, I'm an MS specialist don't know much about Unix.

bcolflesh

3:21 pm on Jan 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Add an .htaccess to the directory with Indexes turned off:

Options -Indexes

Frank_Rizzo

3:28 pm on Jan 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can also turn it off globally in the httpd.conf file.

Another good idea is to put a basic index.html file in every directory (apart from your root obviously).

Harry

3:36 pm on Jan 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So when people log into the directory they see a basic page where I can put a link to what I want them to see and not what's included in the directory?

Harry

3:36 pm on Jan 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Also, is there a specific thing I have to write for the http access. I don't want to mess up anything, as I'm not a tech guy.

robert adams

6:26 pm on Jan 5, 2004 (gmt 0)

10+ Year Member



Just create a page with whatever you want on it. Name it index.html and then visitors will only get that page and not see whatever is in the directory.

luck,
robert

g1smd

3:27 pm on Jan 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



As well as turning DirectoryIndex off in Apache and other servers, you can create a basic:

<html><head></head><body></body></html>

page that will display as a blank and stop people listing the files within.

However, I would make it more useful by redirecting to the home page.

You could also throw people off the trail with a fake error message like "Contents of Virtual Directory cannot be listed" that you see on some sites when you attempt to shorten the path of a dynamic URL to go higher in the site structure.

mbauser2

5:52 am on Jan 23, 2004 (gmt 0)

10+ Year Member



And finally, the old school way, just in case you don't have .htaccess permissions:

While in the directory above /widget/, "chmod o-r widget" on the command line.

(The webserver can't get a directory listing if it doesn't have read access to the directory, but it can still serve individual files by name. "man chmod" for the gory details on file permissions.)

onlineleben

9:08 am on Jan 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>> <html><head></head><body></body></html>

page that will display as a blank and stop people listing the files within.

However, I would make it more useful by redirecting to the home page. <<

When redirecting to homepage, you could get into problems with SEs.
I would use the blank page (example above) to put links to my homepage, product page etc or just promote an affiliateprogram

Harry

1:44 pm on Jan 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why do redirects cause problems for search engines. If a page no longer exist and is linked to why be penalized for directing people to the right spot?

I have an old home.htm that I removed recently. The index.htm was a frame. I changed index from a frame to a normal page and I no longer need the home.htm.

I find it odd and somewhat insulting to have search engines tell me what I can or cannot do with my own Web site. I'm not spamming, I'm cleaning up clutter.

g1smd

8:13 pm on Jan 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If your orphaned pages redirecting the visitor to someplace else could be called doorways then that is when your idea of clearing up clutter overlaps the search engines' definition of spam.

Unfortunately.