【发布时间】: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/chgrpWeb 服务器用户,并检查目录层次结构的权限。
标签: php apache .htaccess kohana