腾迅真狠空间封了无处申诉 發表於 2025-6-13 00:00:00

wordpress发布时链接地址依然指向本地而不是域名解决方法

<p>忙碌了n天,我的wordpress终于挂到了公网上,开始内侧,不过出现了问题,上面所有的链接,不管是自己博客中的链接,还是wordpress系统的页面跳转链接,都依然指向localhost,而不是我的域名。好吧,逢山开路,遇水搭桥,这是我们IT人的优良品质,我开始找解决方案。</p>
<p>在wordpress官网中提供了n中情况的解决方法,包括你的wordpress名称改变,或是wordpress的路径改变,伙食URL改变等等,这里我只介绍我的情况,就是URL的改变。</p>
<p>When Your Domain Name or URLs Change当你的域名或者URL改变了,比如 - i.e. from http://example.com/blog to http://example.com, or http://example.com to http://newexample.com - t,虽然我们的数据库已经移动了,但这些域名或URL还存储在数据库中,一次造成了链接问题。</p>
<p><strong>官方提供了两种方案</strong>:</p>
<p>Only perform a search and replace on the wp_posts table.Use the Search and Replace for WordPress Databases Script to safely change all instances. ( If you are a developer, use this option. It is a one step process as opposed to the 15-step procedure below )</p>
<p>第一种我认为他只修改了日志的链接,效果不好,于是我采用了第二种方案。</p>
<p>首先下载相应php脚本http://interconnectit.com/124/search-and-replace-for-wordpress-databases/&nbsp;,解压后得到searchreplacedb2.php,放置在你的wordpress根目录下(和wp-config.php)同级。</p>
<p>然后通过浏览器访问对应的searchreplacedb2,如www.example.com/wordpress/searchreplacedb2.php,如下图。</p>
<p><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250613/1-2506131F254963.png" /></p>
<p>让你选择获取数据库信息的方法,点击下一步:</p>
<p><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250613/1-2506131F254122.png" /></p>
<p>确认无误后,点击下一步:</p>
<p><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250613/1-2506131F255616.png" /></p>
<p></p>
<p>选择你要替换字段的表名,这里全选即可:点击下一步:</p>
<p><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250613/1-2506131F255Z3.png" /></p>
<p><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250613/1-2506131F255B2.png" /></p>
<p>在查找和替换中分别输入你要查找和替换的名字,下一步则ok,</p>
<p><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250613/1-2506131F2551N.png" /></p>
<p>ok,记得吧searchreplacedb2.php这个文件给删除掉啊,免得误操作了。</p>
頁: [1]
查看完整版本: wordpress发布时链接地址依然指向本地而不是域名解决方法