我在使用.htaccess在我的新服务器上工作时遇到了一些非常令人沮丧的问题。 我在pipe理服务器方面并不是很有经验,但是我已经花了三天的时间翻阅文档和所有可以获得的资源。
我试图尝试一个非常基本的.htaccess的应用程序,但它没有给出预期的结果。 我已经build立了一个testing目录。 立即在这个目录下是一个.htaccess文件,使用下面的命令:
否认所有
如果我没有弄错,这应该拒绝访问/testing,但它不会。 它只是坐在那里让任何人查看内容。 我已经做了一个可读的.htaccess可用在同一目录中的任何人想看到我的.htaccess到底是怎么回事。
我的服务器/configuration有什么问题? 服务器正在运行CentOS。
对Dom的回应
# AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None
如上所示,我将其更改为AllowOverride All ,然后重新启动我的服务器:
service httpd restart
但收到以下消息:
/etc/httpd/conf/httpd.conf的第347行语法错误:
AllowOverride不允许在这里[FAILED]
最后一行是347行:
# UserDir: The name of the directory that is appended onto a user's home # directory if a ~user request is received. # # The path to the end user account 'public_html' directory must be # accessible to the webserver userid. This usually means that # ~useridllowOverride controls what directives may be placed in # .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None
您的虚拟主机configuration中是否有AllowOverride All ? 如果您有AllowOverride None ,那么.htaccess文件不会被读取,所以不会被使用。 对了,
否认所有
独自禁止连接到文件夹。 不要忘记重新加载Apache