WordPress: Changing The Site URL:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
无编辑摘要
 
(未显示同一用户的5个中间版本)
第1行: 第1行:
__TOC__
__TOC__
__TOC__
WordPress stores two addresses inside the database. These determine where your blog files are, and where the main index is. On a normal install, these addresses are the same.


WordPress在数据库中储存了两个地址。这两个地址决定了你的博客文件的位置和主索引的位置。在一次普通安装中,这些地址都是相同的。
WordPress在数据库中储存了两个地址。这两个地址决定了你的博客文件的位置和主索引的位置。在一次普通安装中,这些地址都是相同的。
There are two occasions where you will need to access the database to alter one or both of these settings:


在两种情况下,你需要访问数据库来更改一个或者这两个设置。
在两种情况下,你需要访问数据库来更改一个或者这两个设置。


# If you have tried to alter the Blog URL or WordPress URL in Options and an error has occurred.
#如果你试图在选项中更改博客URL或者WordPress URL,会出现一个错误。
#如果你试图在选项中更改博客URL或者WordPress URL,会出现一个错误。
# If you have moved to a domain/subdomain with a different name.
#如果你使用了一个不同的名称,移到了一个域/子域。
#如果你使用了一个不同的名称,移到了一个域/子域。


<div style="border:red solid 4px; margin:20px; padding:10px;font-weight:bold">
<div style="border:red solid 4px; margin:20px; padding:10px;font-weight:bold">
BACKUP your database before you begin and store the backup off your site server, like on your hard drive. See: [[WordPress:Backing Up Your Database]].
在你开始和储存备份之前,将你的数据库在你的站点服务器上备份,例如在你的硬盘上。请看看: [[WordPress:Backing Up Your Database|备份你的数据库]]。
</div>
 
<div style="border:red solid 4px; margin:20px; padding:10px;font-weight:bold">
在你开始和储存备份的之前,将你的数据库在你的站点服务器上备份,例如在你的硬盘上。请看看: [[WordPress:Backing Up Your Database|备份你的数据库]]。
</div>
</div>
==Changing the URL==


==更改 URL==
==更改 URL==
# [[WordPress:Backing Up Your Database|Backup your database]] and save the copy off-site.
# [[WordPress:Backing Up Your Database|备份你的数据库]] 并且保存 copy off-site。
# [[WordPress:Backing Up Your Database|备份你的数据库]] 并且保存 copy off-site。
# Login to [[WordPress:phpMyAdmin]].
#登录到[[WordPress:phpMyAdmin|phpMyAdmin]]。
#登录到[[WordPress:phpMyAdmin|phpMyAdmin]]。
# Click the link to your '''Databases'''.
#点击链接,连接到你的'''数据库'''。
#点击链接,连接到你的'''数据库'''。
# A list of your databases will appear. Choose the one that is your WordPress database.
#你的数据库的一个列表会显示。选择一个你的WordPress的数据库。
#你的数据库的一个列表会显示。选择一个你的WordPress的数据库。
# All the tables in your database will appear on the screen.
#你的数据库中所有的表格都会出现在界面上。
#你的数据库中所有的表格都会出现在界面上。
 
#从列表中,查找'''<tt>wp_options</tt>'''。'''注:'''如果你在安装的时候更改了,<tt>wp_</tt>的表格前缀可能会有所不同。
# From the list, look for '''<tt>wp_options</tt>'''. '''Note:''' The table prefix of <tt>wp_</tt> may be different if you changed it when installing.
 
#从列表中,查找'''<tt>wp_选项</tt>'''。'''注:'''如果你在安装的时候更改了,<tt>wp_</tt>的表格前缀可能会有所不同。
 
# Click on the small icon indicated as '''Browse'''.
#点击显示为'''浏览'''的小图标。
#点击显示为'''浏览'''的小图标。
# A screen will open with a list of the fields within the '''<tt>wp_options</tt>''' table.
#一个界面会打开,上面有'''<tt>wp_选项</tt>'''表格中的一些栏。
#一个界面会打开,上面有'''<tt>wp_选项</tt>'''表格中的一些栏。
 
#'''<tt>option_name</tt>'''栏的下面,下滚并且查找'''<tt>siteurl</tt>'''。
# Under the field '''<tt>option_name</tt>''', scroll down and look for '''<tt>siteurl</tt>'''.
 
#在'''<tt>选项_名</tt>'''栏的下面,下滚并且查找'''<tt>siteurl</tt>'''。
 
# Click the '''Edit Field''' icon which usually is found at the far left at the beginning of the row.
 
#点击'''编辑 栏'''图标,这个图标通常位于首行的最左边。
#点击'''编辑 栏'''图标,这个图标通常位于首行的最左边。
# The '''Edit Field''' window will appear.
#'''编辑 栏'''窗口就会出现。
#'''编辑 栏'''窗口就会出现。
 
#'''<tt>option_value</tt>'''输入框中,认真地将URL信息改为新的地址。
# In the input box for '''<tt>option_value</tt>''', carefully change the URL information to the new address.
 
#在'''<tt>选项_值</tt>'''输入框中,认真地将URL信息改为新的地址。
 
# Verify this is correct and click '''Go''' to save the information.
#确认这是正确的并且点击'''Go'''(运行)来保存信息。
#确认这是正确的并且点击'''Go'''(运行)来保存信息。
 
#你应该被返回到你的'''<tt>wp-options</tt>'''表格。
# You should be returned to your '''<tt>wp-options</tt>''' table.
#查找表格中的'''<tt>home</tt>'''区,并且点击'''编辑field '''。'''注''':在<tt>wp_options</tt>中有几个网页的表格。在这些网页中,查找<tt>&gt;</tt>符号。
#你应该被返回到你的'''<tt>wp-选项</tt>'''表格。
#'''<tt>option_value</tt>'''的输入框中,认真地将URL信息改为新的地址。
 
# Look for the '''<tt>home</tt>''' field in the table and click '''Edit Field'''. '''Note''' There are several pages of tables inside <tt>wp_options</tt>. Look for the <tt>&gt;</tt> symbol to page through them.
 
#查找表格中的'''<tt>home</tt>'''区,并且点击'''编辑field '''。'''注''':在<tt>wp_选项</tt>中有几个网页的表格。在这些网页中,查找<tt>&gt;</tt>符号。
 
# In the input box for '''<tt>option_value</tt>''', carefully change the URL information to the new address.
 
#在'''<tt>选项_值</tt>'''的输入框中,认真地将URL信息改为新的地址。
 
# Verify this is correct and click '''Go''' to save the information.
 
#核查这是正确的,并且点击'''Go'''(运行)来保存信息。
#核查这是正确的,并且点击'''Go'''(运行)来保存信息。
 
#删除文件夹''wp-content/cache''(这是添加到WordPress2.0上新的文件夹)。
# Delete the folder ''wp-content/cache'' (this is a new folder added with WordPress 2.0).
 
#删除文件夹''wp-内容/高速缓存''(这是添加到WordPress2.0上新的文件夹)。
 
# That is it.
 
#就这么多了。
#就这么多了。
== Domain Name Change ==


== 更改域名 ==
== 更改域名 ==
<div style="border: red 3px solid; margin:20px; padding:10px; font-weight:bold; text-align:center">
BE VERY CAREFUL WITH THIS.


<div style="border: red 3px solid; margin:20px; padding:10px; font-weight:bold; text-align:center">
<div style="border: red 3px solid; margin:20px; padding:10px; font-weight:bold; text-align:center">
请认真对待。
请认真对待。
IT WILL HURT.


会有不好的影响。
会有不好的影响。
BACKUP YOUR DATABASE FIRST: [[WordPress:Backing Up Your Database]].


首先备份你的数据库:[[WordPress:Backing Up Your Database|备份你的数据库]]。
首先备份你的数据库:[[WordPress:Backing Up Your Database|备份你的数据库]]。
The following is irreversible. There is no "undo" or "undelete" button. This is permanent. Be warned that it can do harm.
</div>


下面的执行是不能够取消的。没有"取消"或者 "恢复被删除文件"按钮。这个执行是永久性的。要注意这个步骤不会引起不好的后果。
下面的执行是不能够取消的。没有"取消"或者 "恢复被删除文件"按钮。这个执行是永久性的。要注意这个步骤不会引起不好的后果。
</div>
</div>
When moving the domain, you will need to [[WordPress:Restoring_Your_Database_From_Backup|restore the database]]. You then need to upload your files to their new location.


当移动域的时候,你需要[[WordPress:Restoring_Your_Database_From_Backup|重建数据库]]。然后你需要将你的文件上传到新的位置上。
当移动域的时候,你需要[[WordPress:Restoring_Your_Database_From_Backup|重建数据库]]。然后你需要将你的文件上传到新的位置上。
'''At this point, your blog will NOT work.'''


'''这时,你的博客不能够运行。'''
'''这时,你的博客不能够运行。'''
# '''Database'''
# '''数据库'''
# '''数据库'''
## Follow the guide above to alter the information in the database.
##遵循上述的指南来更改数据库中的信息。
##遵循上述的指南来更改数据库中的信息。
# '''Database Entries'''


# '''数据库内容'''
# '''数据库内容'''
## Log into [[WordPress:phpMyAdmin]].
##登录到[[WordPress:phpMyAdmin|phpMyAdmin]]。
##登录到[[WordPress:phpMyAdmin|phpMyAdmin]]。
## [[WordPress:Backing Up Your Database|Backup your database]] and save the copy off-site.
##[[WordPress:Backing Up Your Database|备份你的数据库]]并且保存copy off-site。
##[[WordPress:Backing Up Your Database|备份你的数据库]]并且保存copy off-site。
## Login to [[WordPress:phpMyAdmin]].
##登录到[[WordPress:phpMyAdmin|phpMyAdmin]]。
##登录到[[WordPress:phpMyAdmin|phpMyAdmin]]。
## Click the link to your '''Databases'''.
##点击,链接到你的'''数据库'''。
##点击,链接到你的'''数据库'''。
## A list of your databases will appear. Choose the one that is your WordPress database.
##会显示一列你的数据库。选择一个你的WordPress的数据库。
##会显示一列你的数据库。选择一个你的WordPress的数据库。
 
##查找数据库中用来放置你的文章信息的表格的名称。通常名称是<tt>wp_posts</tt>,但是有可能这个名称已经更改了。将这个名称写下来。
## Look for the name of the table within your database used to hold your post information. Usually it is called <tt>wp_posts</tt>, but it may have been changed.  Write it down.
 
##查找数据库中用来放置你的文章信息的表格的名称。通常名称是<tt>wp_文章</tt>,但是有可能这个名称已经更改了。将这个名称写下来。
 
## Clicking the '''Browse''' icon or link, open the <tt>wp_posts</tt> table.
 
##点击'''浏览'''图标或者链接,打开<tt>wp_文章</tt>表格。
##点击'''浏览'''图标或者链接,打开<tt>wp_文章</tt>表格。
## Look for the field that holds your post "guid".  It is usually called <tt>guid</tt>, but it may have been changed.  Write it down.
##查找包含你的文章"guid"的区域。这个区通常称为<tt>guid</tt>,但是这个名称可能已经更改了。将这个名称写下来。
##查找包含你的文章"guid"的区域。这个区通常称为<tt>guid</tt>,但是这个名称可能已经更改了。将这个名称写下来。
## Click the tab at the top for '''SQL'''.
##点击顶上方的标签来'''SQL'''。
##点击顶上方的标签来'''SQL'''。
## Using the information you wrote down from above and the old and new URL addresses you wish to '''update''' or search and replace within your database, type in the following ('''CAREFULY'''):<br />
##使用你在上述步骤中写下的信息和你想要'''更新'''或者搜索的旧的和新的URL地址,在你的数据库中替换地址,输入以下的内容('''认真地'''):<br />
##使用你在上述步骤中写下的信息和你想要'''更新'''或者搜索的旧的和新的URL地址,在你的数据库中替换地址,输入以下的内容('''认真地'''):<br />
<pre>UPDATE wp_posts SET guid = REPLACE (
guid,
'http://exampleoldsiteurl.com',
'http://examplenewsiteurl.com');</pre>
<pre>UPDATE wp_posts SET guid = REPLACE (
<pre>UPDATE wp_posts SET guid = REPLACE (
guid,
guid,
'http://exampleoldsiteurl.com',
'http://exampleoldsiteurl.com',
'http://examplenewsiteurl.com');</pre>
'http://examplenewsiteurl.com');</pre>
## Make sure that the names of <tt>wp-posts</tt> and <tt>post_content</tt> match the tables and fields within your database. Change them if not.


##要确保<tt>wp-posts</tt> 和<tt>post_content</tt>名称与你的数据库内的表格和表格栏向匹配。如果不匹配的话,就要更改这些名称。
##要确保<tt>wp-posts</tt> 和<tt>post_content</tt>名称与你的数据库内的表格和表格栏向匹配。如果不匹配的话,就要更改这些名称。
## Ensure that the ONLY content you want to change are within the little '''single 'quotes' '''. Make sure EVERYTHING is spelled right and that you are sure this is correct.
##要确保你想要更改的内容在小的'''单 '引号' '''之内。要确保所有的内容都是正确拼写的而且你确定这些拼写是正确的。
##要确保你想要更改的内容在小的'''单 '引号' '''之内。要确保所有的内容都是正确拼写的而且你确定这些拼写是正确的。
## Review everything within the '''SQL''' input box again. Make sure it is correct. There are no second changes when you take the next action. The change is permanent.
##在一次地在'''SQL'''输入框中阅读所有的内容。要确保这些内容是正确的。当你执行下一个步骤的时候,就没有再次更改的机会了。下一步中的更改是永久性的。
##在一次地在'''SQL'''输入框中阅读所有的内容。要确保这些内容是正确的。当你执行下一个步骤的时候,就没有再次更改的机会了。下一步中的更改是永久性的。
## When you are sure, click '''Go'''.
##当你确定的时候,点击'''Go'''(运行)。
##当你确定的时候,点击'''Go'''(运行)。
## At the top of the screen will be generated a list of how many of the tables and fields have been changed.
##在界面的上方,会产生一个列表,显示了更改了多少个表格和表格栏。
##在界面的上方,会产生一个列表,显示了更改了多少个表格和表格栏。
== Changing Template Files ==


== 更改模板文件 ==
== 更改模板文件 ==


In your [[WordPress:Using Themes|WordPress Theme]], open each template file and search for any manually entered references to your old domain name and replace it with the new one. Look for specific hand coded links you may have entered on the various template files such as the <tt>sidebar.php</tt> and <tt>footer.php</tt>.
在你的[[WordPress:Using Themes|WordPress主题]]中,打开每个模板文件并且搜索任何动手给你的旧域名输入references,并且将这个替换为新的。查找特别的手工编码的链接,你可能将这些链接输入到不同的模板文件中,例如<tt>sidebar.php</tt>和<tt>footer.php</tt>。
 
在你的[[WordPress:Using Themes|WordPress主题]]中,打开每个模板文件并且搜索任何动手给你的老域输入references,并且将这个替换为新的。查找特别的手工编码的链接,你可能将这些链接输入到不同的模板文件中,例如<tt>sidebar.php</tt>和<tt>footer.php</tt>。
 
WordPress uses a template tag called <tt>[[WordPress:Template Tags/bloginfo|bloginfo()]]</tt> to automatically generate your site address from information entered in your [[WordPress:Administration_Panels#Options_-_Configuration_Settings|Options]] panel. The tag in your template files will not have to be modified. 


WordPress使用一个称为<tt>[[WordPress:Template Tags/bloginfo|bloginfo()]]</tt>的模板标签,自动地从输入进你的[[WordPress:Administration_Panels#Options_-_Configuration_Settings|选项]]模板的信息中,产生你的站点地址。你的模板文件中的标签不需要更改。
WordPress使用一个称为<tt>[[WordPress:Template Tags/bloginfo|bloginfo()]]</tt>的模板标签,自动地从输入进你的[[WordPress:Administration_Panels#Options_-_Configuration_Settings|选项]]模板的信息中,产生你的站点地址。你的模板文件中的标签不需要更改。
==Changing the Config file ==


==更改 Config 文件 ==
==更改 Config 文件 ==
You will need to update your WordPress configuration file if your database has moved or changed in certain ways.


如果你的数据库在某种程度上更改了或者移动了,你就需要更新WordPress配置文件。
如果你的数据库在某种程度上更改了或者移动了,你就需要更新WordPress配置文件。


# You will only need to modify the config file if:
#你只需要更改配置文件,如果:
#你值需要更改配置文件,如果:
 
## your database has moved to another server and is not running on your <tt>localhost</tt>
##你的数据库移到另一个服务器而且不在<tt>本地主机</tt>上运行。
##你的数据库移到另一个服务器而且不在<tt>本地主机</tt>上运行。
## you have renamed your database
##你需要重新命名你的数据库
##你需要重新命名你的数据库
## you have changed the database user name
##你更改了数据库用户名
##你更改了数据库用户名
# "'Make a backup copy of your <tt>wp-config.php</tt> file.'"
# "'制作一个 <tt>wp-config.php</tt> 文件的备份拷贝。'"  
# "'制作一个 <tt>wp-config.php</tt> 文件的备份拷贝。'"  
# Open the <tt>wp-config.php</tt> file in a [[WordPress:Glossary#Text editor|text editor]].
#打开[[WordPress:Glossary#Text editor|文本编辑器]]中的<tt>wp-config.php</tt>文件。
#打开[[WordPress:Glossary#Text editor|文本编辑器]]中的<tt>wp-config.php</tt>文件。
# Review its contents. In particular, you are looking for the [http://codex.wordpress.org/Editing_wp-config.php#Database_host database host entry].
#阅读文件内容。你要特别查找[http://codex.wordpress.org/Editing_wp-config.php#Database_host 数据库主机内容]。
#阅读文件内容。你要特别查找[http://codex.wordpress.org/Editing_wp-config.php#Database_host 数据库主机内容]。
# Save the file.
#保存文件。
#保存文件。


At this point, your WordPress blog should be working.
这时,WordPress博客应该可以运行。
这时,WordPress博客应该可以运行。


== Verify the Profile ==
== 验证个人基本资料 ==
 
== 核实个人基本资料 ==
 
# In your [[WordPress:Administration Panels]] go to [[WordPress:Administration_Panels#Options_-_Configuration_Settings|Options]] > [[WordPress:Administration_Panels#General|General]]. Here you will verify that the changes you made in [http://codex.wordpress.org/Changing_The_Site_URL#Changing_the_URL Changing the URL] above, are correct.
 
#在[[WordPress:Administration Panels|管理面板]]中,进入[[WordPress:Administration_Panels#Options_-_Configuration_Settings|选项]] > [[WordPress:Administration_Panels#General|总的]]。这儿会确认你在上面的[http://codex.wordpress.org/Changing_The_Site_URL#Changing_the_URL 更改 URL]上所作的更改是正确的。
#在[[WordPress:Administration Panels|管理面板]]中,进入[[WordPress:Administration_Panels#Options_-_Configuration_Settings|选项]] > [[WordPress:Administration_Panels#General|总的]]。这儿会确认你在上面的[http://codex.wordpress.org/Changing_The_Site_URL#Changing_the_URL 更改 URL]上所作的更改是正确的。
# Verify that the reference in your '''WordPress URI''' contains the new address.
#确认你的'''WordPress URI'''中包含的参考包含了新的地址。
#确认你的'''WordPress URI'''中包含的参考包含了新的地址。
# Verify that the reference in your "Blog URI" contains the new address.
#确认你的"博客 URI"中的参考包含了新的地址。
#确认你的"博客 URI"中的参考包含了新的地址。
# If you have made changes, click '''Update Options'''.
#如果你更改了,点击'''更新选项'''。
#如果你更改了,点击'''更新选项'''。
== Changing the .htaccess file ==


== 更改 .htaccess 文件 ==
== 更改 .htaccess 文件 ==
After changing the information in your [[WordPress:Administration_Panels#Options_-_Configuration_Settings|Options]] > [[WordPress:Administration_Panels#General|General]] panel, you will need to update your <tt>.htaccess</tt> file if you are using [[WordPress:Using Permalinks|Permalinks]] or any rewrites or redirects.


在[[WordPress:Administration_Panels#Options_-_Configuration_Settings|选项]] > [[WordPress:Administration_Panels#General|总]] 面板上更改了信息之后,如果你正使用[[WordPress:Using Permalinks|Permalinks]]或者其它的rewrites或者redirects的话,你需要更新你的<tt>.htaccess</tt>文件。
在[[WordPress:Administration_Panels#Options_-_Configuration_Settings|选项]] > [[WordPress:Administration_Panels#General|总]] 面板上更改了信息之后,如果你正使用[[WordPress:Using Permalinks|Permalinks]]或者其它的rewrites或者redirects的话,你需要更新你的<tt>.htaccess</tt>文件。
# '''Make a backup copy of your <tt>.htaccess</tt> file.''' This is not a recommendation but a requirement.


#'''做一个 <tt>.htaccess</tt> 文件的备份。'''这并不是一个建议而是一个要求。
#'''做一个 <tt>.htaccess</tt> 文件的备份。'''这并不是一个建议而是一个要求。
# Open the <tt>.htaccess</tt> file in a [[WordPress:Glossary#Text editor|text editor]].
#在一个[[WordPress:Glossary#Text editor|文字编辑器]]中打开<tt>.htaccess</tt>文件。
#在一个[[WordPress:Glossary#Text editor|文字编辑器]]中打开<tt>.htaccess</tt>文件。
# Review its contents, looking for any custom rewrites or redirects you entered. '''Copy''' these to another text file for safe keeping.
#阅读这个文件的内容,并且查找你输入的任何自定义rewrites或者redirects。将这些内容'''拷贝'''到另一个文字编辑器中以便安全地保存。
#阅读这个文件的内容,并且查找你输入的任何自定义rewrites或者redirects。将这些内容'''拷贝'''到另一个文字编辑器中以便安全地保存。
# Close the file.
#关闭文件。
#关闭文件。
# Follow the instructions on the Permalinks SubPanel for updating your Permalinks to the <tt>.htaccess</tt> file.
#遵循Permalinks子面板上的指示说明,将你的Permalinks更新到<tt>.htaccess</tt>文件。
#遵循Permalinks子面板上的指示说明,将你的Permalinks更新到<tt>.htaccess</tt>文件。
# Open the new <tt>.htaccess</tt> file and check to see if your custom rewrites and redirects are still there.  If not, copy them from the saved file and paste them into the new <tt>.htaccess</tt> file.
#打开新的<tt>.htaccess</tt>文件并且查看你的rewrites和redirects是否还在那儿。如果不在,从保存的文件中复制rewrites和redirects,并且将其粘贴进新的<tt>.htaccess</tt>文件。
#打开新的<tt>.htaccess</tt>文件并且查看你的rewrites和redirects是否还在那儿。如果不在,从保存的文件中复制rewrites和redirects,并且将其粘贴进新的<tt>.htaccess</tt>文件。
# Make any changes necessary in those custom rewrites and redirects to reflect the new site address.
#在那些自定义的rewrites和redirects中做一些必要的更改,反映新的站点地址。
#在那些自定义的rewrites和redirects中做一些必要的更改,反映新的站点地址。
# Save the file.
#保存文件。
#保存文件。
# Test those redirects to ensure they are working.
#测试这些redirects,确保这些redirects正在运行。
#测试这些redirects,确保这些redirects正在运行。
If you make a mistake, you can [[WordPress:Restoring Your Database From Backup]] from your backup and try this again. So make sure it is right the first time.


如果你犯了一个错误,你可以从你的文件备份中[[WordPress:Restoring Your Database From Backup|从文件备份中重建数据库]]并且在做一次重建。确保第一次就是对的。
如果你犯了一个错误,你可以从你的文件备份中[[WordPress:Restoring Your Database From Backup|从文件备份中重建数据库]]并且在做一次重建。确保第一次就是对的。
== Additional Information ==


== 额外信息 ==
== 额外信息 ==
Much of this information was taken from [http://www.tamba2.org.uk/wordpress/ Podz' WordPress Guides] where this topic is also discussed.


大多数信息是来自[http://www.tamba2.org.uk/wordpress/ Podz的WordPress 指导] ,这个话题在这里也得到了讨论。
大多数信息是来自[http://www.tamba2.org.uk/wordpress/ Podz的WordPress 指导] ,这个话题在这里也得到了讨论。
See also: [http://www.clearpointsystems.com/wp04/?page_id=19 How to move a WordPress blog to a new URL or domain]


也看看:[http://www.clearpointsystems.com/wp04/?page_id=19 怎样将 WordPress博客移到一个新的 URL或者域]
也看看:[http://www.clearpointsystems.com/wp04/?page_id=19 怎样将 WordPress博客移到一个新的 URL或者域]

2008年6月26日 (四) 18:02的最新版本

WordPress在数据库中储存了两个地址。这两个地址决定了你的博客文件的位置和主索引的位置。在一次普通安装中,这些地址都是相同的。

在两种情况下,你需要访问数据库来更改一个或者这两个设置。

  1. 如果你试图在选项中更改博客URL或者WordPress URL,会出现一个错误。
  2. 如果你使用了一个不同的名称,移到了一个域/子域。

在你开始和储存备份之前,将你的数据库在你的站点服务器上备份,例如在你的硬盘上。请看看: 备份你的数据库

更改 URL[ ]

  1. 备份你的数据库 并且保存 copy off-site。
  2. 登录到phpMyAdmin
  3. 点击链接,连接到你的数据库
  4. 你的数据库的一个列表会显示。选择一个你的WordPress的数据库。
  5. 你的数据库中所有的表格都会出现在界面上。
  6. 从列表中,查找wp_options注:如果你在安装的时候更改了,wp_的表格前缀可能会有所不同。
  7. 点击显示为浏览的小图标。
  8. 一个界面会打开,上面有wp_选项表格中的一些栏。
  9. option_name栏的下面,下滚并且查找siteurl
  10. 点击编辑 栏图标,这个图标通常位于首行的最左边。
  11. 编辑 栏窗口就会出现。
  12. option_value输入框中,认真地将URL信息改为新的地址。
  13. 确认这是正确的并且点击Go(运行)来保存信息。
  14. 你应该被返回到你的wp-options表格。
  15. 查找表格中的home区,并且点击编辑field :在wp_options中有几个网页的表格。在这些网页中,查找>符号。
  16. option_value的输入框中,认真地将URL信息改为新的地址。
  17. 核查这是正确的,并且点击Go(运行)来保存信息。
  18. 删除文件夹wp-content/cache(这是添加到WordPress2.0上新的文件夹)。
  19. 就这么多了。

更改域名[ ]

请认真对待。

会有不好的影响。

首先备份你的数据库:备份你的数据库

下面的执行是不能够取消的。没有"取消"或者 "恢复被删除文件"按钮。这个执行是永久性的。要注意这个步骤不会引起不好的后果。

当移动域的时候,你需要重建数据库。然后你需要将你的文件上传到新的位置上。

这时,你的博客不能够运行。

  1. 数据库
    1. 遵循上述的指南来更改数据库中的信息。
  1. 数据库内容
    1. 登录到phpMyAdmin
    2. 备份你的数据库并且保存copy off-site。
    3. 登录到phpMyAdmin
    4. 点击,链接到你的数据库
    5. 会显示一列你的数据库。选择一个你的WordPress的数据库。
    6. 查找数据库中用来放置你的文章信息的表格的名称。通常名称是wp_posts,但是有可能这个名称已经更改了。将这个名称写下来。
    7. 点击浏览图标或者链接,打开wp_文章表格。
    8. 查找包含你的文章"guid"的区域。这个区通常称为guid,但是这个名称可能已经更改了。将这个名称写下来。
    9. 点击顶上方的标签来SQL
    10. 使用你在上述步骤中写下的信息和你想要更新或者搜索的旧的和新的URL地址,在你的数据库中替换地址,输入以下的内容(认真地):
UPDATE wp_posts SET guid = REPLACE (
guid,
'http://exampleoldsiteurl.com',
'http://examplenewsiteurl.com');
    1. 要确保wp-postspost_content名称与你的数据库内的表格和表格栏向匹配。如果不匹配的话,就要更改这些名称。
    2. 要确保你想要更改的内容在小的单 '引号' 之内。要确保所有的内容都是正确拼写的而且你确定这些拼写是正确的。
    3. 在一次地在SQL输入框中阅读所有的内容。要确保这些内容是正确的。当你执行下一个步骤的时候,就没有再次更改的机会了。下一步中的更改是永久性的。
    4. 当你确定的时候,点击Go(运行)。
    5. 在界面的上方,会产生一个列表,显示了更改了多少个表格和表格栏。

更改模板文件[ ]

在你的WordPress主题中,打开每个模板文件并且搜索任何动手给你的旧域名输入references,并且将这个替换为新的。查找特别的手工编码的链接,你可能将这些链接输入到不同的模板文件中,例如sidebar.phpfooter.php

WordPress使用一个称为bloginfo()的模板标签,自动地从输入进你的选项模板的信息中,产生你的站点地址。你的模板文件中的标签不需要更改。

更改 Config 文件[ ]

如果你的数据库在某种程度上更改了或者移动了,你就需要更新WordPress配置文件。

  1. 你只需要更改配置文件,如果:
    1. 你的数据库移到另一个服务器而且不在本地主机上运行。
    2. 你需要重新命名你的数据库
    3. 你更改了数据库用户名
  2. "'制作一个 wp-config.php 文件的备份拷贝。'"
  3. 打开文本编辑器中的wp-config.php文件。
  4. 阅读文件内容。你要特别查找数据库主机内容
  5. 保存文件。

这时,WordPress博客应该可以运行。

验证个人基本资料[ ]

  1. 管理面板中,进入选项 > 总的。这儿会确认你在上面的更改 URL上所作的更改是正确的。
  2. 确认你的WordPress URI中包含的参考包含了新的地址。
  3. 确认你的"博客 URI"中的参考包含了新的地址。
  4. 如果你更改了,点击更新选项

更改 .htaccess 文件[ ]

选项 > 面板上更改了信息之后,如果你正使用Permalinks或者其它的rewrites或者redirects的话,你需要更新你的.htaccess文件。

  1. 做一个 .htaccess 文件的备份。这并不是一个建议而是一个要求。
  2. 在一个文字编辑器中打开.htaccess文件。
  3. 阅读这个文件的内容,并且查找你输入的任何自定义rewrites或者redirects。将这些内容拷贝到另一个文字编辑器中以便安全地保存。
  4. 关闭文件。
  5. 遵循Permalinks子面板上的指示说明,将你的Permalinks更新到.htaccess文件。
  6. 打开新的.htaccess文件并且查看你的rewrites和redirects是否还在那儿。如果不在,从保存的文件中复制rewrites和redirects,并且将其粘贴进新的.htaccess文件。
  7. 在那些自定义的rewrites和redirects中做一些必要的更改,反映新的站点地址。
  8. 保存文件。
  9. 测试这些redirects,确保这些redirects正在运行。

如果你犯了一个错误,你可以从你的文件备份中从文件备份中重建数据库并且在做一次重建。确保第一次就是对的。

额外信息[ ]

大多数信息是来自Podz的WordPress 指导 ,这个话题在这里也得到了讨论。

也看看:怎样将 WordPress博客移到一个新的 URL或者域