wordpress 403 禁止:允许访问图像
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9173880/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
403 forbidden: permission to access images
提问by Rob
I'm currently building a new version of a site in Wordpress and trying to add a few images as normal to be referenced both by CSS & HTML. Weirdly it's allowed me to add several images like the logo etc yet when I try to add a few more images it's giving the forbidden message below. The image doesn't appear either and the forbidden message below shows when I goto the path of the image.
我目前正在 Wordpress 中构建一个新版本的网站,并尝试正常添加一些图像以供 CSS 和 HTML 引用。奇怪的是,它允许我添加多个图像,例如徽标等,但是当我尝试添加更多图像时,它给出了下面的禁止消息。当我转到图像的路径时,图像也不会出现,并且下面的禁止消息显示。
Forbidden
You don't have permission to access /v2/wp-content/themes/default/images/contact-yellow-icon.png on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
禁止的
您无权访问此服务器上的 /v2/wp-content/themes/default/images/contact-yellow-icon.png。此外,在尝试使用 ErrorDocument 处理请求时遇到 404 Not Found 错误。
I've never had this problem before out of the several other WP sites I've setup. What could be the problem?
在我设置的其他几个 WP 站点中,我从未遇到过这个问题。可能是什么问题呢?
If I put in the path to another image then it works fine (http://www.domain.com/v2/wp-content/themes/default/images/contact-innovation-logo.png) so don't know why it won't allow me to access the other images!?
如果我放入另一个图像的路径,那么它工作正常(http://www.domain.com/v2/wp-content/themes/default/images/contact-innovation-logo.png)所以不知道为什么它不允许我访问其他图像!?
回答by ookami.kb
you should check file permissions for /v2/wp-content/themes/default/images/contact-yellow-icon.png
您应该检查 /v2/wp-content/themes/default/images/contact-yellow-icon.png 的文件权限
i think they should be 644 so that all can read that file
我认为它们应该是 644,以便所有人都可以读取该文件
or you can check file permissions of /v2/wp-content/themes/default/images/contact-innovation-logo.png
或者您可以检查 /v2/wp-content/themes/default/images/contact-innovation-logo.png 的文件权限
you can change permissions with ftp manager or with shell
您可以使用 ftp manager 或 shell 更改权限
** updated by Eric Leroy if file permissions 644 does not work, change to 755 that is what I used to fix the issue. If you are not familiar on how to do this on *inx based, and mac systems, here is how: Open terminal and navigate to the parent folder of the images. type sudo chmod -R 775 (then type the name of your images folder after 775 ) it will ask you for your password, then your images will work on your website.
** 由 Eric Leroy 更新,如果文件权限 644 不起作用,请更改为 755,这是我用来解决问题的方法。如果您不熟悉如何在基于 *inx 的系统和 mac 系统上执行此操作,方法如下:打开终端并导航到图像的父文件夹。输入 sudo chmod -R 775 (然后在 775 之后输入图像文件夹的名称)它会询问您的密码,然后您的图像将在您的网站上工作。
回答by Kc Gibson
This can also be caused by using hotlinking protection. So if hotlinking protection is used, make sure that the URL for your website is added to the white list. Also keep in mind that www.yourdomain.com and yourdomain.com are considered two different URLs.
这也可能是由于使用盗链保护造成的。因此,如果使用盗链保护,请确保将您网站的 URL 添加到白名单中。另请记住,www.yourdomain.com 和 yourdomain.com 被视为两个不同的 URL。
回答by Chris
The question may have been solved for the original user, but I found no amount changing permissions or disabling hotlinking (was already disabled) was working for me.
这个问题可能已经为原始用户解决了,但我发现没有任何改变权限或禁用盗链(已经被禁用)对我有用。
For me the files not working were php files in the themes CSS and JavaScript directories.
对我来说,不起作用的文件是主题 CSS 和 JavaScript 目录中的 php 文件。
I found that for me the problem was a .htaccess file that WordPress created for a LOCKDOWN to prevent malicious code injections. Adding rules to allow these files allowed them to work.
我发现对我来说问题是 WordPress 为 LOCKDOWN 创建的 .htaccess 文件,以防止恶意代码注入。添加规则以允许这些文件允许它们工作。
回答by Sudip Das
Use this
用这个
sudo chmod -R a+rw /var
and then
进而
<img src="../img/y.png">