• I’m moving a blog from a dedicated subdomain (https://blog.) to a subdirectory under the main domain (/blog/). I’ve done this by setting up a new WP installation in the subdirectory and then exporting the data from the previous blog and importing it to the new one.

    It mostly works, but there are problems with the permalinks. Here’s what I know.

    • With the permalinks set to “plain” everything works as it should.
    • When I change the permalinks to “month and name” they stop working.
    • Changing the permalinks setting does not write an htaccess file to the subdirectory.
    • Manually copying an htaccess file into the subdirectory changes the behaviour, but doesn’t fix things.

    Without an htaccess file, clicking a link gives an Apache 404 page as I would expect. But when I add an htaccess file that changes to give a plain text file simply saying “File not found.” I assume that’s generated by WordPress.

    So, I think I see two weird things here:

    1. Changing the permalink settings doesn’t write an htaccess file.
    2. Even with an htaccess file, the permalinks don’t work.

    I’ve checked that the WP user has write access to the subdirectory (and I don’t get the htaccess error message that I’d expect to see if that wasn’t the case).

    This is WP Version 4.9.5 with only the WordPress importer plugin installed.

    Here’s the manual htaccess file that I’ve been using:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    

    Please let me know if there’s any other information that could be useful to diagnose this issue.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must change all of the URLS inside the database. You can not just import the content into a new location. The urls to the pages are stored in there.

    Use a db search and replace utility like:https://interconnectit.com/products/search-and-replace-for-wordpress-databases/

    to change db urls

    Thread Starter davorg

    (@davorg)

    Thanks for your suggestion.

    Could you please confirm which columns in which tables need to be updated?

    I thought that the URL would be generated from posts.post_name and various installation-level pieces of information – so I don’t think I need to update those.

    There’s a column in the posts table called “guid” which seemed to contain the old-style URL. I’ve updated those, but I see no change in behaviour.

    Thread Starter davorg

    (@davorg)

    Some further investigation.

    I created a new post on the new installation (the one in the subdirectory) and it exhibited exactly the same behaviour as the migrated posts.

    I think that means the migration isn’t the problem here and I don’t need to change anything in the database.

    Any other suggestions would be appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Broken Permalinks’ is closed to new replies.