WordPress.org

Ready to get started?Download WordPress

Forums

Permalinks Break after Server Migrations (32 posts)

  1. gdawkins
    Member
    Posted 3 years ago #

    I do many wordpress migrations form one server to another in my line of work at http://ezsitemove.com and I was wondering why migrating a wordpress installation to another server breaks the permalinks? Clicking on the normal wordpress pages after a migration will produce a 404 error.

    It's a pretty simple fix, login to the admin section, navigate to your permalink structure and hit "save". You don't even have to change them. Simply saving them fixes the error.

    However, I can't help to think that this is a bug. Even if it's not a "bug" per se, it would still be really nice to have it fixed.

    I await some feedback on the matter.

    Gary

  2. Because you have to rebuild the permalink rules for the new server. Saving them rebuilds the data in your database.

  3. gdawkins
    Member
    Posted 3 years ago #

    Hey Ipstenu,

    What if I want to automatically rebuild them in the database?

    After uploading the database to the new server the permalink_structure is correct:
    /%year%/%monthnum%/%day%/%postname%/

    That part doesn't change, so what is it that actually changes when the "Save" button is clicked in the admin section and where can I manually update those in the database so that I don't have to login to the admin section to do it?

    I appreciate the help,

    Gary

  4. That's an answer I wish I knew. :( It's a pain for a moved MultiSite install, and I have yet to sort out how.

  5. PixelPie
    Member
    Posted 3 years ago #

    Anyone fix the broken permalinks issue?. I too have done a server migration and permalinks cause 404 error.

  6. gdawkins
    Member
    Posted 3 years ago #

    Have you logged into your admin section and clicked "Save" for your permalink structure? Also, you can double check that you have the right information in your .htaccess file, a default wordpress .htaccess should look like:

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

    Don't forget to update the two entries in your database's wp_options table as well.

  7. PixelPie
    Member
    Posted 3 years ago #

    Hi gdawkins

    'Don't forget to update the two entries in your database's wp_options table as well'. Could you elaborate?

  8. gdawkins
    Member
    Posted 3 years ago #

    Yes, in your wp_options table you'll need to update your "SiteURL" row on page 1 and your "Home" row on page 2. You'd usually use phpMyAdmin to do so.

    I forgot to mention, this is just for cases where you've changed your domain name or directory structure of the wordpress install. If you're using the same domain and didn't change directories then you won't need to worry about this step.

  9. PixelPie
    Member
    Posted 3 years ago #

    Ok I will try it out, many thanks for your speed reply.

  10. PixelPie
    Member
    Posted 3 years ago #

    what do I update the SiteUrl row and the Home row with?

  11. gdawkins
    Member
    Posted 3 years ago #

    The full URL to your current wordpress blog:

    For example: http://example.com/blog

  12. PixelPie
    Member
    Posted 3 years ago #

    Hi

    Yes they are correct, but still getting 404 error. The homepage of the site loads but the links to other pages are broken.

  13. gdawkins
    Member
    Posted 3 years ago #

    Have you logged into your admin section and clicked "Save" for your permalink structure?

  14. PixelPie
    Member
    Posted 3 years ago #

    The internal links work when I revert back to default permalinks but when I change and save to custom the links are broken, 404

    Any ideas?

  15. gdawkins
    Member
    Posted 3 years ago #

    What's the new domain name with the 404 errors on it?

  16. PixelPie
    Member
    Posted 3 years ago #

    when I make custom permalink to /%category%/%postname%/ i get the 404 error

  17. gdawkins
    Member
    Posted 3 years ago #

    Yes, but what is your domain name so that I can take a look at the site?

  18. PixelPie
    Member
    Posted 3 years ago #

  19. gdawkins
    Member
    Posted 3 years ago #

    Ok, which URL's do you have in your database?

    Can you please copy/paste your .htaccess code here.

  20. PixelPie
    Member
    Posted 3 years ago #

    URLs in db http://julianbensonmanagement.com/artists

    There is no htaccess file in the root directory.

  21. gdawkins
    Member
    Posted 3 years ago #

    There should be a .htaccess file in the /artists directory.

    However, I think the problem is the lack of a / on the end of the URL's in the database. Try adding a / to the end and see if that helps.

  22. PixelPie
    Member
    Posted 3 years ago #

    So I added the / at the end of URL for both Site URL and Home in the db. Didnt work

    So maybe it's the lack of htaccess in the root of /artists

    Any ideas?

  23. You can't have pretty permalinks without an .htaccess file (on MOST servers).

    As your links are all like this: http://julianbensonmanagement.com/artists/?page_id=545

    You should be fine. What's not working?

  24. gdawkins
    Member
    Posted 3 years ago #

    @Ipstenu
    He hasn't been using the default permalinks, he just switched to them, he's trying to use a custom permalink structure that doesn't seem to be working.

    /%category%/%postname%/

    Is the one he wants.

    @PixelPie
    Go ahead and create a default .htaccess file for your /artist directory if you're missing one.

  25. PixelPie
    Member
    Posted 3 years ago #

    default as in blank htaccess file?

  26. gdawkins
    Member
    Posted 3 years ago #

    No, default as in the kind of .htaccess file a default install of wordpress would have.

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
  27. I he did switch them on, then the links in the menu should have changed to
    http://julianbensonmanagement.com/artists/PAGENAME

    But yeah, you need an .htaccess in the /artist directory :)

    PixelPie, read this: http://codex.wordpress.org/Using_Permalinks#Using_.22Pretty.22_permalinks

  28. gdawkins
    Member
    Posted 3 years ago #

    Yes, he did switch it on and the permalinks were reading as http://julianbensonmanagement.com/artists/PAGENAME and giving 404's, which is why he went back to the default permalinks for now.

    I think the lack of the .htaccess file may do the trick though so lets see how he comes out after that.

    @PixelPie
    Just remember to change your permalinks back to the custom structure you were trying to use so we can test it again after you've added the .htaccess file.

  29. PixelPie
    Member
    Posted 3 years ago #

    default htaccess added, permission 777 when saving permalink changes, no didnt work.

    just doble check i have htaccess file correct
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

    Should the RewriteRule be artists/index.php (or something like that)

    Another thing when i imported my database during the migration it asked if it was version MySQL 4.1 or 5.1. Im not sure what version the db is so I selected 4.1 ... could this have anything to do with my permalink issue?

  30. gdawkins
    Member
    Posted 3 years ago #

    If you're on a Linux server you won't want 777 permissions since Apache reads that as a security flaw. 644 permissions will be fine. The RewriteRule should be fine as long as this .htaccess file is in your artists folder (along with your wordpress install).

    At this point it'll be hard to pinpoint the issue without going through some troubleshooting steps which is a lot easier with access to the actual server. Perhaps someone else here could help you but I'd suggest seeking professional help so that you can give full access to the server to someone who works with these problems and knows how to troubleshoot them. For example, a problem like this could easily be solved within an hour with access to the server.

Topic Closed

This topic has been closed to new replies.

About this Topic