PHP 科哈纳。 Htaccess 似乎阻止访问子文件夹。

发布于 2024-12-27 07:43:28 字数 1067 浏览 0 评论 0原文

我在一个网站上遇到问题,因为我的 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

I am having an issue with a site in that it seems like my htaccess file (situated in web root) is preventing access to any php files in subdirectories. I've tested this by creating a new test folder and adding a php file to it which does a simple echo. I always get a 500 error.

This issue only recently started happening. The htaccess rules I have are the same as many other sites I run on my own server, however this one site is hosted by a different company. Does anyone know why this could be happening? Could a change on the server have caused this possibly?

This is my htaccess file:

<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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傲影 2025-01-03 07:43:28

请参阅 ServerFault 的此讨论。肯定是权限问题。根据该讨论,请确保父文件夹也具有适当的权限,否则 Apache 无法进入包含 .htaccess 文件的文件夹来读取它。

See this discussion from ServerFault. It's definitely a permissions issue. Per that discussion, make sure the parent folders also have the proper permissions or Apache can't descend into the folder with the .htaccess file to read it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文