如何在Windows上通过XAMPP避免(本地)Wordpress中的图像URL 403错误? [英] How to avoid 403 error for image URLs in (local) Wordpress via XAMPP on Windows?

查看:182
本文介绍了如何在Windows上通过XAMPP避免(本地)Wordpress中的图像URL 403错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows XP SP3-Xampp 1.8.1-PHP 5.4.7-WordPress 3.5.1-(所有驱动器均使用NTFS)

我认为我的问题类似于该问题,但是这些解决方案似乎仅适用于类似Unix的操作系统.

我正在Windows XP(SP3)上通过XAMPP运行Wordpress,但由于我似乎没有文件访问权限,因此未显示某些(但不是全部)图像.当(通过Chrome开发者)在新标签页中向下钻取URL时,出现403错误.

更改文件权限是否也适合我?如果是,我该如何在Windows上进行更改?

解决方案

您的问题很奇怪,也没有描述性. 您没有写出正在使用的version of XamppVersion of PHPversion of Wordpress ..

您没有提供文件夹结构的详细信息(xampp在哪里,图像在哪里?不同的驱动器?路径?NTFS?FAT?

您至少应该发布显示图片和未显示图片的示例代码.

但是... 这是您可能要检查或验证的事物的列表

  • 检查所有相关文件夹的权限是否为755.
  • 以上表示所有wp文件夹(用于测试)和图像文件夹
  • 检查所有图像均具有用于常规php处理的合法名称(仅english characters)
  • 检查图像是否包含长名.
  • 检查网址中是否包含非法字符
  • 在xampp httdocs内放置图像文件夹(是否放置箱) 文件夹.
  • 更好-将其放在wp uploads文件夹中.
  • 检查服务器分隔符/\的脚本(如果您复制并粘贴了路径..)
  • 检查路径(包括图像名称)是否超过256个字符
  • 如果dropbox文件夹在dropbox服务器上,而不在本地计算机上(您未指定),则请确保您使用的是PUBLIC URL.

我遇到的最烦人的问题与英文字符有关.不会出现的图像是否有变音符号,重音符号或非(a-z 0-9)字符?如果是这样,请尝试重命名它们.

在您提供更多详细信息之后,可以更轻松地帮助您查明问题.

编辑我

阅读您的评论后,我相信您所有包含图像的方法都有些偏离,完全不适合xampp或系统的文件夹结构/权限.在我看来,您只是不知道如何在wp主题中包含文件(但我可能是错的..)

在wordpress中,要链接与主题相关的图像,理想情况下,图像应位于主题文件夹wp-content/themes/your_theme/ 或更好

wp-content/themes/your_theme/img/

然后您就可以像这样调用图像(在主题中):

<img src="<?php echo get_template_directory_uri(); ?>/img/yourimage.jpg" />

查看: get_template_directory_uri()

或者,您可以查看 get_stylesheet_directory_uri()编解码器中所述:

define( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/blog/wp-content' ); // in wp-config

define( 'WP_CONTENT_URL', 'http://example/blog/wp-content'); // in wp-config

或仅用于赞扬

define( 'UPLOADS', '/wp-content/uploads' );// in wp-config

还有其他几种方法,但是我敢肯定,通过一些研究,您可以找到它们..

现在,话虽如此,我不确定我是否了解您想要实现的目标,但是如果在某些高级情况下(例如高级图像处理插件)或某些特殊情况,这不是您的特例-问题不在您的图像中也不在您的权限中,它在您的工作流程中以及在wordpress中使用主题图片的方式.

Windows XP SP3 - Xampp 1.8.1 - PHP 5.4.7 - WordPress 3.5.1 - (all drives use NTFS)

I think my problem is similar to this one but these solutions seem only suitable for Unix-like OSs.

I'm running Wordpress via XAMPP on Windows XP (SP3) and some (but not all) images are not displayed because I seem not to have file permissions to access them. When drilling down (via Chrome Developer) to the URL in a new tab, I get a 403 error.

Is changing file permissions the way to go for me too and if so, how do I do that on Windows?

解决方案

Your problem is very strange and also very non descriptive . You did not write what version of Xampp you are using , what Version of PHP , what version of Wordpress..

You did not provide details of your folder structure ( where is xampp, where are the images ? different drives ? path ?? NTFS ? FAT ?

You should at least post some sample code of an image that shows and an image that does not show .

But ... Here is a list of things that you might want to check or verify

  • Check that all the related folders has permissions of 755.
  • The above means ALL wp folders (for testings) AND the images folders
  • Check that all your images have legal names for regular php handling (only english characters )
  • check that the images do not have long names .
  • check that the urls do not contain illegal characters
  • Put your images folder (dropbox or not ) INSIDE the xampp httdocs folder.
  • Better yet - put it inside the wp uploads folder .
  • check your scripts for the server delimiter / or \ (if you copied and pasted the pathes ..)
  • check that the paths do not exceed 256 characters (including the image names)
  • If the dropbox folder is on the dropbox server and not on the local machine (you did not specify that ) than make sure you are using the PUBLIC URL .

The most annoying problem that I have encountered has to do with the point of the english characters . Does the images that DO NOT appear has some umlauts , accents or non ( a-z 0-9 ) characters ?? If they do , try to rename them .

After you will provide some more details , it will be easier to help you pinpoint the problem..

EDIT I

After reading your comment , I believe that all your method of including images is a bit off-course , an not at all realted to xampp or your system´s folder structure / permissions. It seems to me , that you just do not know how to include files in wp themes (but I might be wrong..)

In wordpress, to link theme related images , the images should ideally be located at the theme folder wp-content/themes/your_theme/ or better yet

wp-content/themes/your_theme/img/

then you would just call the images (in your theme) like so :

<img src="<?php echo get_template_directory_uri(); ?>/img/yourimage.jpg" />

look at :get_template_directory_uri()

Alternatively you can look at get_stylesheet_directory_uri() andget_theme_root_uri()

The part where your css images would take a relative part to the css file depends on where you put them in a relative manner . are they in themes/your_theme/img or themes/your_theme/css/img or whatever . at any rate , you call them essentially the same but mind that the images that are called from WITHIN the css will always follow normal rules of css images , not the wordpress one (which is applied to php files) ..

ALL images ( excluding admin ) , as a rule of thumb, should be located under the wp-content folder.

Theme images under themes/your_theme and other images under wp-uploads.

In wp , a path like you described/requested of C:\xampp\htdocs\anneke_00\wp-content\img is non standard , not recommended , and is used only in very extreme cases for very special reasons (surely not for theme display).

If you want , you COULD in theory move your wordpress uploads folder using several methods :

  1. Method A

    • Login into wordpress admin section.
    • Click on settings -> Miscellaneous Settings
    • Apply the file upload folder path.
  2. Method B

as explained in the codex :

define( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/blog/wp-content' ); // in wp-config

define( 'WP_CONTENT_URL', 'http://example/blog/wp-content'); // in wp-config

or only for uplaods

define( 'UPLOADS', '/wp-content/uploads' );// in wp-config

there are several other methods, but I am sure that with a bit of research you could find them ..

Now , that being said , I am not sure that I understood what you want to achieve , but if it is not some special case for some extreme circumstances of an advanced image handling plugin or something - the problem is not in your images nor in your permissions, it is in your workflow and in how you use theme images in wordpress..

这篇关于如何在Windows上通过XAMPP避免(本地)Wordpress中的图像URL 403错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆