WordPress Custom Structure permalinks breaks after

2019-09-13 18:11发布

问题:

I had my WP on a site mysite1.com and am migrating it to mysite2.com, hosted on a different server. I simple ran a find-and-replace in the database, mysite1.com -> mysite2.com, and the homepage mysite2.com now works fine but all the subpages (mysite2.com/subpage1, mysite2.com/subpage2, mysite2.com/subpage1/thing?id=1, etc.) do not work. I'm using the Custom Structure http://mysite2.com/%postname%/, which worked just fine on mysite1.com. All the other Permalink structures work on mysite2.com, I might add. It's when I switch back to the custom structure that the subpages 404.

Could this have something to do with needing to configure my new server or php.ini or anything?

Any ideas on what may be the cause of the problem and what I can do to fix it?

回答1:

Just try putting an .htaccess file on the root of your wordpress. Then change its permission to 755 and the change the permalink structure to postname.

Here is sample .htacess file code.

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

# END WordPress


回答2:

https://codex.wordpress.org/Changing_The_Site_URL

Add these two lines to your wp-config.php, where "example.com" is the correct location of your site.

define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');