php - WordPress 媒体文件上传 403 禁止

标签 php wordpress apache file-upload

我正在尝试在 WordPress 中上传文件,但某些文件出现 http 错误 403 禁止。这些图像具有相同的分辨率,大小几乎没有任何区别,并且 mime 类型也相同。

我使用 apache2 和 php 7.0,但是这个问题似乎在具有不同 php 版本的多个服务器上持续存在。

php.ini 设置

upload_max_filesize = 512M
post_max_size = 128M

我什至尝试将其添加到 .htaccess

<IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteRule ^index\.php$ - [L]

        RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

        # add a trailing slash to /wp-admin
        RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^ - [L]
        RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
        RewriteRule ^(.*\.php)$ $1 [L]
        RewriteRule . index.php [L]
</IfModule>

php_value upload_max_filesize 512M
php_value post_max_size 512M
php_value memory_limit 512M

我没有使用 mod_security,因此上传限制不适用于此处。 这是 apachectl -M 的输出:

Loaded Modules:
 core_module (static)
 so_module (static)
 watchdog_module (static)
 http_module (static)
 log_config_module (static)
 logio_module (static)
 version_module (static)
 unixd_module (static)
 access_compat_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 filter_module (shared)
 mime_module (shared)
 mpm_prefork_module (shared)
 negotiation_module (shared)
 php7_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 status_module (shared)

这似乎是由于防火墙设置造成的,系统管理员尝试停用“协议(protocol)违规”,然后它开始正常工作。

最佳答案

我刚刚遇到了同样的问题。我尝试直接在帖子的编辑器 View 中上传图像。我猜我打开它的时间太长(超过 24 小时)并且某些 token 或其他内容已过期。重新加载编辑器后,它再次正常工作

关于php - WordPress 媒体文件上传 403 禁止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43799682/

相关文章:

php - Jquery/PhP/Joomla 选择两个组合框之一不会更新

PHP:每当调用子类中的函数时调用函数

php - 如何在 WooCommerce 中检查一系列产品 ID

e-commerce - wordpress 最好的电子商务插件是什么?

php - 在 Linux : exec Behavior, 进程 ID 和 grep 上创建 PHP 在线评分系统

php - WordPress 只能使用 777 权限

php - 在 Docker 中启用 Apache SSL 以进行本地开发

php-fpm 不创建 .sock 文件

php - 将网站从 Windows 迁移到 Linux

php - PHP preg_replace 中的\w 仅覆盖 UTF-8 字符的第二个字节