【问题标题】:Wordpress media file upload 403 forbiddenWordpress 媒体文件上传 403 被禁止
【发布时间】:2017-10-03 14:59:46
【问题描述】:

我正在尝试在 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)

这似乎是由于防火墙设置,系统管理员尝试停用“协议违规”并开始正常工作。

【问题讨论】:

    标签: php wordpress apache file-upload


    【解决方案1】:

    我也遇到了同样的问题。我尝试直接在帖子的编辑器视图中上传图片。我想我打开它的时间太长(超过 24 小时)并且某些令牌或某些东西已过期。重新加载编辑器后,它又可以正常工作了

    【讨论】:

      【解决方案2】:

      仅将以下代码添加到 yours.htaccess

      # BEGIN WordPress
      <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteRule ^index\.php$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]
      </IfModule>
      
      # END WordPress
      

      希望对你有用

      【讨论】:

        【解决方案3】:

        我认为你应该检查上传文件夹的文件夹权限。来源:https://codex.wordpress.org/Changing_File_Permissions

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2022-10-01
          • 1970-01-01
          • 2015-07-16
          • 2020-10-05
          • 2013-06-09
          • 2021-04-01
          • 2018-02-20
          相关资源
          最近更新 更多