• I have a strange problem and wonder if someone can advise, please?

    [WP 5.0.4 PHP 7.2]

    I have just migrated my website from a static site to WP and am using the same URL, with WP established in a separate folder.

    The usual ‘copy index.php and .htaccess’ into the ROOT was done together with a small change to the ROOT index.php .

    require(‘./wp-blog-header.php’)

    was changed to

    require(‘./subdirectory/wp-blog-header.php’)

    I manually added 301 redirects in .htaccess for the old site urls to new site urls and they tested fine.

    Everything is working beautifully – I am totally stunned by it.

    However, when I run a link checker I am getting a strange set of 404s reported.
    Each WP page is sending out a 301 and pointing to the URL with the subdomain included.

    The source link text is showing as correct Permalink

    {domain} / { correct WP part}

    but is being seen as

    {domain} / {subfolder} / { correct WP part} and gets a 404.

    I have run Permalink, cleared local caches and Cloudflare many times but the problem remains.

    I also temporarily removed all of my own 301 redirects from the .htaccess file so that WP only saw what it created.

    https://www.deadlinkchecker.com reports
    Status: 404
    URL: {domain} / {subfolder} / { correct WP part}
    Source Link Text : “Link Text [ 301 from {domain} /{ correct WP part}]”

    It is really strange because the site works so well! Is this a real problem which will affect SEO of just a literal interpretation by the link checkers?

    Your wise guidance will be really appreciated !

Viewing 7 replies - 1 through 7 (of 7 total)
  • am using the same URL, with WP established in a separate folder.

    This description of how you did it sort of leaves out a crucial detail. What is in the Settings for Site URL? It should have just your domain, not the subfolder. The WP URL field should have the domain and the subfolder.
    (If you change it, save permalinks again.)

    Thread Starter nigelpt

    (@nigelpt)

    Hi,

    Yes sorry – the brain has gone to mush over here!

    WordPress Address (URL) is set to {domain} / { folder} with no trailing slash

    Site Address (URL) is set to domain only

    Is it the missing trailing slash, I wonder?

    No, I don’t think it’s the trailing slash.
    When you say

    The source link text is showing as correct Permalink
    {domain} / { correct WP part}
    but is being seen as
    {domain} / {subfolder} / { correct WP part} and gets a 404.

    it sounds like before the click the link looks correct, but the resulting page is not correct, so the only thing between the click and WordPress is the .htaccess, unless you have something else like a CDN or cache or something that is interfering.

    Thread Starter nigelpt

    (@nigelpt)

    I’ll disable all caching and CDN, clear all local browser[s] caches and see if that makes any difference.

    I’m at the ‘pushing the eyes back in with a stick’ stage so will have some sleep and come back with a clear[er] mind tomorrow. It is probably something simple awaiting some logical sideways solution!

    Cheers

    Thread Starter nigelpt

    (@nigelpt)

    Hi Joy,

    Firstly thank you very much for taking the time to advise me – very much appreciated.

    I am reporting back for the benefit of anyone who comes across this post.

    There were multiple issues and despite clearing all local caches and CDN, the problem remained.

    However the following worked.

    – I had been trying two different caching plug-ins and one appeared to have left remnants which were cleaned out.
    – Using the Broken Link Checker plug-in I was able to detect a large number of obsolete URLs in page/post links which had not been picked up by refreshing permalinks.

    It took a while to manually correct each one and I now have just 4 to track down but they are proving elusive – for now…

    However, a new issue has been detected!

    The original static site had a section that relied upon query_strings. I converted all 490 of them to static html pages and adding the following to the .htaccess file it all worked like a dream.

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{QUERY_STRING} ID=([0-9]+) [NC]
    RewriteRule (.*) /{folder}/{filename-%1.html? [R=301,L]
    </IfModule>

    domain/file?ID={number} redirected to domain/folder/file-{number}.html

    Now suddenly this has stopped working and all incoming calls to the original URLs are being sent to the WP 404 page.

    I’ve tried several different rules in the .htaccess file, including just testing a single file redirect not no joy. Does the coexistence with WP cause a problem or is the QuerySting “ID” conflicting with WP internally?

    The WordPress section of the .htaccess needs to be at the end of the file.

    Also, your assumption that saving permalinks affects links in content is incorrect. That’s why I was saying “before the click the link looks correct” but that probably didn’t come across correctly. (I typically look at the address in the status bar on hover, before I click, especially when debugging, but a lot of people don’t.)
    Part of the migration task is to make sure all the content links are correct, and the media files are different than the links when you are using WP in a subfolder, although you can set a define for where the wp-content folder is.

    Thread Starter nigelpt

    (@nigelpt)

    Thank you again, Joy.

    As ever, you know all the answers!

    Having the WordPress section at the end of the .htaccess file is obviously something pretty vital which had escaped me – a valuable lesson learned.

    So we are in business – all I need do now is find out why the Menu save button gives no clue when the task is complete.

    Thanks again!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Static to WP migration – good but getting 404s’ is closed to new replies.