php 服务器无法读取 htaccess 文件,拒绝访问是安全的

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42849166/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:42:56  来源:igfitidea点击:

Server unable to read htaccess file, denying access to be safe

php.htaccess

提问by APARNNA MS

403 FORBIDDEN

403 禁止

You don't have permission to access/folder_name/index.phpon this server.

您无权access/folder_name/index.php访问此服务器。

Server unable to read .htaccessfile, denying access to be safe

服务器无法读取.htaccess文件,拒绝访问以确保安全

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocumentto handle the request.

此外,在尝试使用ErrorDocument处理请求时遇到 403 Forbidden 错误。

Here is .htaccesscode:

这是.htaccess代码:

<Files 403.shtml> 
order allow,
deny allow from all 
</Files> 

And I also tried another code:

我还尝试了另一个代码:

<Directory "/path/to/source/file/directory/www"> 
Options Indexes FollowSymLinks 
AllowOverride all 
Require all granted 
</Directory> 

But I am confused on the line "path/to/source/file/directory/www".

但我对“path/to/source/file/directory/www”这一行感到困惑。

回答by Roshan Kumara

Make sure that the .htaccessfile is readable by apache:

确保.htaccess文件可读apache

chmod 644 access/folder_name/.htaccess 

And make sure the directory which contains .htaccessis readable and executable:

并确保包含的目录.htaccess可读和可执行:

chmod 755 access/folder_name/

回答by Prince Paul

If you are using cpanel, then go to the public HTMLfolder or else which subfolder creating the problem. right click the folder, you get the option, change permission. make alternative changes accordingly so you can make live your web page enter image description here

如果您正在使用cpanel,则转到公共HTML文件夹或创建问题的子文件夹。右键单击该文件夹,您将获得更改权限的选项。相应地进行替代更改,以便您可以使您的网页上线 在此处输入图片说明

回答by Black

I had the same issue. I am on rackspeed and use cpanel. I created a subdomain which also created the base folder. But I deleted the base folder and created it again, which caused the error.

我遇到过同样的问题。我在机架速度并使用 cpanel。我创建了一个子域,它也创建了基本文件夹。但是我删除了基本文件夹并重新创建了它,这导致了错误。

I had to open the subdomain configuration and edit the base directory. The correct base directory was already entered but I had to do It again nevertheless, to make it reinitialize.

我必须打开子域配置并编辑基本目录。已经输入了正确的基本目录,但我不得不再次这样做,以使其重新初始化。