如何阻止访问者直接访问我网站上的目录?

时间:2022-11-29 21:14:52

I have a (Wordpress powered) website, and Google is indexing some of the sub-directories. How can I stop Apache from showing users the directory listing? I know I can edit .htaccess to password-protect a directory, but I would prefer a 403 / custom redirect if possible.

我有一个(Wordpress驱动的)网站,谷歌正在索引一些子目录。如何阻止Apache向用户显示目录列表?我知道我可以编辑.htaccess来密码保护目录,但如果可能的话我更喜欢403 /自定义重定向。

3 个解决方案

#1


12  

You need this entry in your .htaccess file:

您需要在.htaccess文件中输入此条目:

Options -Indexes

#2


3  

Look at your robots.txt rules, and make sure apache is not serving-up directory listings.

查看您的robots.txt规则,并确保apache不提供目录列表。

see http://httpd.apache.org/docs/2.0/howto/htaccess.html && http://www.webmasterworld.com/forum92/5272.htm

见http://httpd.apache.org/docs/2.0/howto/htaccess.html&& http://www.webmasterworld.com/forum92/5272.htm

#3


-2  

Don't know much about Apache but you should do a 404 instead of a 403 if you can because a 403 tells someone that they may have found something interesting.

不太了解Apache,但如果可以,你应该做404而不是403,因为403告诉别人他们可能找到了一些有趣的东西。

#1


12  

You need this entry in your .htaccess file:

您需要在.htaccess文件中输入此条目:

Options -Indexes

#2


3  

Look at your robots.txt rules, and make sure apache is not serving-up directory listings.

查看您的robots.txt规则,并确保apache不提供目录列表。

see http://httpd.apache.org/docs/2.0/howto/htaccess.html && http://www.webmasterworld.com/forum92/5272.htm

见http://httpd.apache.org/docs/2.0/howto/htaccess.html&& http://www.webmasterworld.com/forum92/5272.htm

#3


-2  

Don't know much about Apache but you should do a 404 instead of a 403 if you can because a 403 tells someone that they may have found something interesting.

不太了解Apache,但如果可以,你应该做404而不是403,因为403告诉别人他们可能找到了一些有趣的东西。