在 WordPress 中,主题文件夹中的 .php 文件无法运行,但返回 404 错误
顺便说一句,我在 VPS 环境中,所以我有 root 访问权限。
返回 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
由于您具有 root 访问权限,请尝试查找 Apache 日志中发生的情况。要跟踪最新的请求,您可以使用 tail。
您正在运行哪个版本的 Apache?在我的 Apache 2.2 配置中,您可以通过调用以下命令来跟踪终端中的错误日志:
看来 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:
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
.当文件本身也是可写的时,也会发生相同的错误。确保文件是 644 而不是 666!
Same error can occur when the file it self is also writable. Make sure the file is 644 and NOT 666 !
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.
这是由 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.)
就我而言,以下权限更改解决了 (Timthumb.php) 问题:
“644”
。“755”
;既不是“775”
,也不是“777”
。In my case, the following PERMISSION changes solved the (Timthumb.php) issue:
"644"
."755"
; Neither"775"
nor"777"
.