在 WordPress 中,主题文件夹中的 .php 文件无法运行,但返回 404 错误

发布于 2024-08-20 07:49:25 字数 722 浏览 6 评论 0原文

顺便说一句,我在 VPS 环境中,所以我有 root 访问权限。

那么请看一下这些问题: http://www.sonikastudios.com/wp-content/themes/sonikas/scripts/timthumb.php?src=/wp-content/uploads/tedleescreenshot1。 jpg&w=100&h=100&zc=1&q=100

返回 404 错误。

但是,当我将 timthumb.php 移动到网站的根目录时,它就可以工作了。

我验证了文件/文件夹权限,这不是问题。另外,我用于验证码的另一个 PHP 生成的图像正在做同样的事情......

所以本质上它可以归结为没有从文件夹内运行的 .php 文件。不过,这不是问题,因为我在其他站点上的 /admin/ 下的 PHP 脚本工作正常。

那么...什么可能导致这种情况?我读到的大多数论坛文章都倾向于 mod_security 问题,但我什至不知道从哪里开始,因为我不是 apache 专家。

I'm on a VPS environment so I have root access, btw.

So take a look at these issues:
http://www.sonikastudios.com/wp-content/themes/sonikas/scripts/timthumb.php?src=/wp-content/uploads/tedleescreenshot1.jpg&w=100&h=100&zc=1&q=100

That returns a 404 error.

However when I move timthumb.php to the root of the site, it works.

I verified file/folder permissions, it's not the issue. Also, another PHP generated image that i use for Captcha, is doing the same thing...

So essentially it boils down to no .php files running from within folders. However this is not an issue otherwise because PHP scripts I have under /admin/ on other sites work fine.

So... what could cause this? Most forum articles I read lean towards a mod_security problem, but I don't even know where to start, as I'm not an apache expert.

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

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

发布评论

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

评论(5

心如荒岛 2024-08-27 07:49:25

由于您具有 root 访问权限,请尝试查找 Apache 日志中发生的情况。要跟踪最新的请求,您可以使用 tail。

您正在运行哪个版本的 Apache?在我的 Apache 2.2 配置中,您可以通过调用以下命令来跟踪终端中的错误日志:

tail -f /var/log/httpd/error_log

看来 Apache 2.2的默认配置有错误日志在 /usr/local/apache2/logs/error_log 中,所以我的配置不是默认的。

如果错误日志没有成功,请尝试在访问日志中查找信息,默认位置为 /usr/local/apache2/logs/access_log

As you have root access, try looking for what is happening in Apache logs. To follow latest request you can use tail.

Which version of Apache you are running? In my configuration of Apache 2.2 you can follow error log in terminal by invoking:

tail -f /var/log/httpd/error_log

It seems that default configuration of Apache 2.2 has error log in /usr/local/apache2/logs/error_log, so my configuration is not default.

If you do not have success with error log, try also looking for information in access log, default location at /usr/local/apache2/logs/access_log.

我的鱼塘能养鲲 2024-08-27 07:49:25

当文件本身也是可写的时,也会发生相同的错误。确保文件是 644 而不是 666!

Same error can occur when the file it self is also writable. Make sure the file is 644 and NOT 666 !

静若繁花 2024-08-27 07:49:25

WordPress 可能使用一些 mod_rewrite 规则将每个请求发送到其 < em>index.php。它会分析请求并在请求其内部之一时返回 404 状态代码。

Wordpress is probably using some mod_rewrite rules to send every request to its index.php. And there it’s analyzing the request and returning a 404 status code if one of its internals was requested.

掐死时间 2024-08-27 07:49:25

这是由 WordPress 生成的 .htaccess 文件的问题。它将您网站上非 wp-admin/ 或上传目录中的所有请求重定向到 WordPress 的 index.php 文件(查询帖子等的请求处理程序)

This is a problem with your .htaccess file generated by WordPress. It redirects all requests for your site that aren't wp-admin/ or in your uploads directory to the index.php file for WordPress (the request handler that queries for posts, etc.)

偷得浮生 2024-08-27 07:49:25

就我而言,以下权限更改解决了 (Timthumb.php) 问题:

  1. PHP 脚本必须是“644”
  2. 所有父目录必须是“755”;既不是“775”,也不是“777”

In my case, the following PERMISSION changes solved the (Timthumb.php) issue:

  1. The PHP script must be "644".
  2. All of the parent directories must be "755"; Neither "775" nor "777".
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文