gdawkins
Member
Posted 1 year 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
Because you have to rebuild the permalink rules for the new server. Saving them rebuilds the data in your database.
gdawkins
Member
Posted 1 year 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
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.
PixelPie
Member
Posted 1 year ago #
Anyone fix the broken permalinks issue?. I too have done a server migration and permalinks cause 404 error.
gdawkins
Member
Posted 1 year 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.
PixelPie
Member
Posted 1 year ago #
Hi gdawkins
'Don't forget to update the two entries in your database's wp_options table as well'. Could you elaborate?
gdawkins
Member
Posted 1 year 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.
PixelPie
Member
Posted 1 year ago #
Ok I will try it out, many thanks for your speed reply.
PixelPie
Member
Posted 1 year ago #
what do I update the SiteUrl row and the Home row with?
gdawkins
Member
Posted 1 year ago #
The full URL to your current wordpress blog:
For example: http://example.com/blog
PixelPie
Member
Posted 1 year 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.
gdawkins
Member
Posted 1 year ago #
Have you logged into your admin section and clicked "Save" for your permalink structure?
PixelPie
Member
Posted 1 year 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?
gdawkins
Member
Posted 1 year ago #
What's the new domain name with the 404 errors on it?
PixelPie
Member
Posted 1 year ago #
when I make custom permalink to /%category%/%postname%/ i get the 404 error
gdawkins
Member
Posted 1 year ago #
Yes, but what is your domain name so that I can take a look at the site?
PixelPie
Member
Posted 1 year ago #
gdawkins
Member
Posted 1 year ago #
Ok, which URL's do you have in your database?
Can you please copy/paste your .htaccess code here.
PixelPie
Member
Posted 1 year ago #
URLs in db http://julianbensonmanagement.com/artists
There is no htaccess file in the root directory.
gdawkins
Member
Posted 1 year 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.
PixelPie
Member
Posted 1 year 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?
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?
gdawkins
Member
Posted 1 year 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.
PixelPie
Member
Posted 1 year ago #
default as in blank htaccess file?
gdawkins
Member
Posted 1 year 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
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
gdawkins
Member
Posted 1 year 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.
PixelPie
Member
Posted 1 year 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?
gdawkins
Member
Posted 1 year 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.