WordPress Custom Structure permalinks breaks after migrating site to new domain and server

一世执手 提交于 2019-12-11 22:45:21

问题


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');


来源:https://stackoverflow.com/questions/33308056/wordpress-custom-structure-permalinks-breaks-after-migrating-site-to-new-domain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!