Search code examples
wordpresspermissionsxampphttp-status-code-403

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.

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?


Solution

  • 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..