【问题标题】:PHP Kohana. Htaccess seems to be preventing access to subfolder.PHP小花。 Htaccess 似乎正在阻止访问子文件夹。
【发布时间】:2012-02-12 03:23:55
【问题描述】:

我有一个网站问题,我的 htaccess 文件(位于 Web 根目录)似乎阻止访问子目录中的任何 php 文件。我已经通过创建一个新的测试文件夹并向其中添加一个执行简单回显的 php 文件来对此进行测试。我总是收到 500 错误。

这个问题最近才开始发生。我拥有的 htaccess 规则与我在自己的服务器上运行的许多其他站点相同,但是这个站点由另一家公司托管。有谁知道为什么会发生这种情况?服务器上的更改是否可能导致这种情况?

这是我的 htaccess 文件:

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</IfModule>

# Turn on URL rewriting
RewriteEngine On

# Put your installation directory here:
# If your URL is www.example.com/kohana/, use /kohana/
# If your URL is www.example.com/, use /
RewriteBase /

# Protect application and system files from being viewed
RewriteCond $1 ^(app_admin|app_public|system)

# Rewrite to index.php/access_denied/URL
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]

# Do not enable rewriting for other files that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]

Options -Indexes

【问题讨论】:

  • 您的 Apache 错误日志说明了什么?如果您收到 500 错误,Apache 总是会记录一条消息,告诉您问题所在...
  • @Dave - 我得到pcfg_openfile: unable to check htaccess file, ensure it is readable - 但是,htaccess 是可读和可执行的,因为它有 755 个权限。
  • 检查文件的代码页,您的编辑器可能已将其转换为 Apache 不喜欢的某种多字节字符集?该错误表明权限无效,因此对权限进行三重检查,可能是chown/chgrp Web 服务器用户,并检查目录层次结构的权限。

标签: php apache .htaccess kohana


【解决方案1】:

请参阅 ServerFault 中的 this discussion。这绝对是权限问题。根据该讨论,请确保父文件夹也具有适当的权限,否则 Apache 无法进入带有 .htaccess 文件的文件夹来读取它。

【讨论】:

  • 正确。不知道它到底是怎么发生的,但是权限被拧在了父文件夹上。谢谢
猜你喜欢
  • 2014-07-21
  • 2023-04-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-18
相关资源
最近更新 更多