How to avoid 403 error for image URLs in (local) WordPress via XAMPP on Windows?

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.

Read More

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?

Related posts

Leave a Reply

5 comments

  1. 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:xampphtdocsanneke_00wp-contentimg 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..

  2. Right clicking on one of the problematic images in Windows Explorer and going to the “Security” tab, what have you got them set to? The account “Everyone” should have the read permission.

    Are they images which have been uploaded via the WordPress media manager?

  3. If you have the time re install XAMPP and WPress it might work, after resatrting windows, this time install XAMPP in c:apps or d:apps and make sure that folder is read + write for all

    also take care when installing WPREss and XAMPP if they are latest stable and follow the instuctions.

    are any of the config files form a unix site? meaning it was on another sytem and now FTPed or copied here?

  4. As a super ugly workaround, I decided to put all my image files in a Dropbox Public folder and copy-paste their links into my CSS. I still hope to properly solve the problem but for now I can at least carry on with the project.

    I’ll post a better solution here if I find it.

  5. You Need to follow these instructions:

    1. Right-click the directory from which Web browsers are receiving the 403 error. Click the “Properties” entry in the menu.
    2. Click the “Security” tab in the Properties window. Click the first button that is labeled “Edit” in the “Anonymous Access” section. In this window, check the box that says “Anonymous Access.” Click “OK” to return to the Properties window.
    3. Click the “Directory” tab in the Properties window. Ensure that no other check boxes except “Read” are checked in the “Permissions” section. This allows users to read and browse website pages. Click the “OK” button.
    4. Verify the changes by opening your Web browser and entering the website domain in the address bar.

    Few options may differ depending upon the Windows version. I’m running Windows 7. Check to see if above solution works for you.