php 迁移后 wordpress 中的网站重定向到旧 URL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20122583/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Website in wordpress redirects to old URL after migration
提问by cristiano matos
I had never done migrating a site on wordpress, I'll put step by step how I did, need to put the site on a new domain that are on the same server, so only the migrated files, the database is equal.
我从来没有在 wordpress 上迁移过一个站点,我会一步一步地说明我是怎么做的,需要将站点放在同一台服务器上的新域上,所以只有迁移的文件,数据库是平等的。
I copied all the files from the old wordpress to the new site folder, I had the following result on the new site: Home - The site carries the theme but a message appears: 404: PAGE OR FILE NOT FOUND. newsite/wp-admin/ - redirect to oldsite/wp-admin/
我将旧 wordpress 中的所有文件复制到新站点文件夹中,在新站点上得到以下结果:主页 - 该站点带有主题,但出现一条消息:404:找不到页面或文件。newsite/wp-admin/ - 重定向到 oldsite/wp-admin/
I have the option in the site administrator old put the new URL but I'm afraid I could never access. it can go?
我可以选择在站点管理员旧的地方放新的 URL 但恐怕我永远无法访问。它可以去吗?
Thanks.
谢谢。
回答by The Humble Rat
You need to make a change to your database. In the database table wp_options (or whatever your database prefix is), you need to change two lines.
您需要对数据库进行更改。在数据库表 wp_options (或任何您的数据库前缀)中,您需要更改两行。
One should be option_id1, option_namesiteurl. Change the option_valuefrom the old url to the new url.
一个应该是option_id1,option_namesiteurl。改变option_value从旧网址到新网址。
Similarly there should also be option_id36, option_namehome. Change the option_valuealso from the old url to the new url.
同样也应该有option_id36,option_name家。将option_value也从旧网址更改为新网址。
This should do the trick. Also check out http://wp.smashingmagazine.com/2013/04/08/moving-wordpress-website/for the best method to migrate.
这应该可以解决问题。另请查看http://wp.smashingmagazine.com/2013/04/08/moving-wordpress-website/以获得最佳迁移方法。
Edit
编辑
In the comments Damon also mentions the issue with re-linking all the images. This for sure can be a right pain, but I suggest this plugin.
在评论中,Damon 还提到了重新链接所有图像的问题。这肯定是一个正确的痛苦,但我建议使用这个插件。
http://wordpress.org/plugins/search-and-replace/
http://wordpress.org/plugins/search-and-replace/
Just search for the old url and replace with the new one. Before doing this though, make sure you have a backup of the database. You can never guarantee the results when using plugins to mess with your database. But this has always worked for me.
只需搜索旧网址并替换为新网址即可。不过,在执行此操作之前,请确保您有数据库的备份。当使用插件弄乱你的数据库时,你永远无法保证结果。但这一直对我有用。
回答by A.Aleem11
I've solved my issue with my solution at No# 04 See below what I tried:
我已经在 No# 04 上用我的解决方案解决了我的问题,请参阅下面我的尝试:
1- Make sure Database wp_option links are set
1- 确保设置了数据库 wp_option 链接
/* MySQL: */
update wp_options set option_value = 'http://example.com' where option_name = 'siteurl';
update wp_options set option_value = 'http://example.com' where option_name = 'home';
2- Additionally define url in wp-config.php file
2-另外在 wp-config.php 文件中定义 url
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
3- Clear cache of from server
3-从服务器清除缓存
4- Clear your browser cache & history (Hurray!!! it solved my issue no redirection)
4- 清除浏览器缓存和历史记录(万岁!!!它解决了我的问题,没有重定向)
On Chrome, Navigate to chrome://settings/clearBrowserDataand clear image and file cache.
在 Chrome 上,导航到chrome://settings/clearBrowserData并清除图像和文件缓存。
回答by Maxime
I think i need to give my contribution! In case you are using Polylangwith a dynamic IP, add define('PLL_CACHE_HOME_URL', false);in your wp-config.phpand it will solve all your problems (redirection to the former url)!
我想我需要做出我的贡献!如果您使用Polylang的是动态 IP,请添加define('PLL_CACHE_HOME_URL', false);您的IP,wp-config.php它将解决您的所有问题(重定向到以前的 url)!
回答by user3630842
define('WP_HOME','domain.com');
define('WP_SITEURL','domain.com');
This goes in your wp-config.php
这在你的 wp-config.php 中
Also, be sure to clear your cache and use this script to replace ALL urls in your database.
此外,请务必清除缓存并使用此脚本替换数据库中的所有 url。
回答by Yannickv
My redirection issue was due to caching. If you do not want to have to clear all your cache and you are using Chrome:
我的重定向问题是由于缓存。如果您不想清除所有缓存并且您正在使用 Chrome:
Right click anywhere on the page > inpect element> Networktab > tick disable cache. Then in that same Chrome tab try to load your website again.
右键单击页面上的任意位置 > inpect element>Network选项卡 > 勾号disable cache。然后在同一个 Chrome 标签中尝试再次加载您的网站。
回答by Jakir Hossain
If this setting not work: define('WP_HOME','domain.com'); define('WP_SITEURL','domain.com');
如果此设置不起作用:define('WP_HOME','domain.com'); 定义('WP_SITEURL','domain.com');
Try a new browser and clear cache. or try to disable all plugins and check if it working.
尝试新的浏览器并清除缓存。或尝试禁用所有插件并检查它是否有效。
Mine worked after i removed cache.
我在删除缓存后工作。
回答by user2841183
STILL if nothing works
STILL 如果没有任何效果
GOTO : www.yoursiteurl.com/wp-admin
['YES' IT WILL OPEN , if you have migrated correctly]
转到:www.yoursiteurl.com/wp-admin
['YES' 它将打开,如果您已正确迁移]
GOTO : Settings => General Tab =>
转到:设置 => 常规选项卡 =>
you will see two fields their
你会看到他们的两个字段
- Wordpress Address URL - Enter your site URL
- Site Address URL - Enter your site URL
- Wordpress 地址 URL - 输入您的站点 URL
- 站点地址 URL - 输入您的站点 URL
Make URLs same in Both fields SAVE changes
使两个字段中的 URL 相同 保存更改
Enter your site URL in browser clear cache and reload Yeahhh.... Worked for me
在浏览器清除缓存中输入您的站点 URL 并重新加载 Yeshh .... 为我工作
Enjoy
享受
Dont forget to modify WP_Options table with your site URL details. Take care my site
不要忘记使用您的站点 URL 详细信息修改 WP_Options 表。小心 我的网站

