404 error on some image access after copying site (7 posts)

  1. hapzfl
    Posted 3 years ago #

    I thought I successfully copied my site from a remote server to my PC by using all the advice I could find on the WordPress sites by changing URL information in my local MySQL database and in WordPress.

    Most everything works but I have a persistent 404 error when trying to access some detailed blog information that deals with attachments.

    Let me try to describe the access procedure when it works:
    (I tested that creating a new post with image)
    and on the remote server
    shows my main blog page.

    When selecting a blog I get locally
    and on the remote server
    Both show the blog with all text and images.
    The images are identified as
    localhost:12345/index.php/2012/12//25/pagename/dsc01234/ etc.
    and on the server as
    http://www.site.com/wordpress/2012/12/25/pagename/dsc01234/ etc.

    And when I select one of these imags on localhost I get a screen localhost:12345/index.php/2012/12//25/pagename/dsc01234/
    with that image and the image is identified as

    Similarily on the remote server I get

    But here is what happens when I try to do the same procedure with a post downloaded from the remote server to localhost:

    shows the blog with the text and images.

    However, when I now select one of the images I get the following error message:
    HTTP error 404.0
    Requested URL localhost:12345/2012/12/22/postname/dsc01222/
    Physical Path D:\Sitename\2012\12\22\postname\dsc01222\

    Of course, the proper physical path would be:

    Thus when I type in the proper URL by adding index.php:
    I get the proper screen w/o an error.

    So why is the index.php reference missing from the requested URL?

    It seems to me that my local database still has some flaws. So I compared the original database entries (wp-posts) on the remote server with the same entries on my localhost. Here is the comparison.

    post_content on the remote server where the attachment is shown properly:

    <p><img alt="DSC01222" class="alignleft size-medium wp-image-8685" height="224" src="http://www.site.com/wordpress/wp-content/uploads/2012/12/DSC01222-400x224.jpg" width="400" /></p>

    and on localhost where the 404 error is created:

    <p><img alt="DSC01222" class="alignleft size-medium wp-image-8685" height="224" src="http://localhost:54603/wp-content/uploads/2012/12/DSC01222-400x224.jpg" width="400" /></p>

    Similar html code; only the URL is different. On the remote server it works, on the localhost I get the error.

    Any help on getting this resolved is very much appreciated.

  2. Peter
    Posted 3 years ago #


    and on localhost where the 404 error is created:

    <p><img alt="DSC01222" class="alignleft size-medium wp-image-8685" height="224" src="http://localhost:54603/wp-content/uploads/2012/12/DSC01222-400x224.jpg" width="400" /></p>

    are you missing "Sitename" ?

  3. hapzfl
    Posted 3 years ago #

    No, that's not it, unfortunately. I wish it were, although than the question would be: how come?

    If you compare the localhost code with that on the remote server the statements are exactly the same aside from the URL. That's what's so puzzling: how can the same code produce different results?

    The localhost html page code is stored in the MySQL database and was converted from the original using Wordepress procedures.

  4. Peter
    Posted 3 years ago #

    Ok check your mysql database for localhost:12345// and you'll have to do a search and replace for '//' to '/'

  5. hapzfl
    Posted 3 years ago #

    nice idea but no, there were no // to replace

  6. hapzfl
    Posted 3 years ago #

    The problem definitely has to do with permalink settings because some stuff I can get to work with one setting and other stuff with another on localhost. Only on the remote server everything works.

    The problem I am trying to resolve:

    On localhost the image has a href=http://localhost/2012/12/21/page_name/dsc123456 this is NOT working, i.e this reference is not found.
    However, the src=http://localhost/wp-content/uploads/.... is working

    On the remote server
    href=http://site.com/wordpress/2012/12/21/page_name/dsc123456/ this is working.

    Obviously replacing "site.com/wordpress" with localhost in the database does not do the trick as all the href references containing ../page_name/... are invalid on localhost. The physical path does not exist.

  7. hapzfl
    Posted 3 years ago #

    ok, in principle I found what I have to do in wp_posts/post_content:

    find in href= the string: "localhost/year/"

    copy from that record the id# from: rel="attachment wp-att-id#"

    replace in that record in href= the string
    "http://localhost/year/...." with

    What I am missing now is a way to accomplish that programmatically. I assume there might be a way with an SQL query, or with other software tackling an exported sql file?

    I have no knowledge whatsoever with SQL queries or how to do it otherwise. Any help is very much appreciated as there are several thousand records that need to be changed.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.