php 如何更改 Wordpress 中的 ABSPATH?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24269955/
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
How to change the ABSPATH in Wordpress?
提问by Lisa S
I've been trying to create a dummy duplicate of a custom-built WP/WooCommerce Site on the same server.
我一直在尝试在同一台服务器上创建一个定制的 WP/WooCommerce 站点的虚拟副本。
I've successfully moved the files to a subdomain and created a temp DB copy and updated the wp_config file, but I cannot for the life of me figure out how to set the ABSPATH value to reflect the subdomain instead of the main (non-test) domain. So now when you log in to the dummy WP site, it logs into the WP dashboard of the MAIN site.
我已经成功地将文件移动到一个子域并创建了一个临时数据库副本并更新了 wp_config 文件,但我一生都无法弄清楚如何设置 ABSPATH 值来反映子域而不是主域(非测试) ) 领域。所以现在当你登录虚拟 WP 站点时,它登录到 MAIN 站点的 WP 仪表板。
**So my question is how do I change the ABSPATH value for the dummy site and will that also update the dummy URLs to point to the site URLs?
**所以我的问题是如何更改虚拟站点的 ABSPATH 值,这是否也会更新虚拟 URL 以指向站点 URL?
The main site URL is ldtuttle.com and the dummy site is dev.tuttle.com.
主站点 URL 是 ldtuttle.com,虚拟站点是 dev.tuttle.com。
Thanks in advance for your time, Lisa
提前感谢您的时间,丽莎
回答by stephenspann
There are two values in the 'wp_options' database table you need to change, 'siteurl' and 'home'.
您需要更改“wp_options”数据库表中的两个值,“siteurl”和“home”。
This will tell Wordpress where to redirect a user for the login screen, and is normally filled out automatically when Wordpress initially creates the database on a domain.
这将告诉 Wordpress 将用户重定向到登录屏幕的位置,并且通常在 Wordpress 最初在域上创建数据库时自动填写。
回答by Kreeverp
You need to update more than Just the 'wp_options'
您需要更新的不仅仅是“wp_options”
Also create a separate database for the- "dummy duplicate" - copy the original database there and then, update these database tables:
还要为“虚拟副本”创建一个单独的数据库 - 在那里复制原始数据库,然后更新这些数据库表:
UPDATE wp_options SET option_value = REPLACE(option_value, 'ORIGINAL_URL', 'NEW_URL');
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'ORIGINAL_URL', 'NEW_URL');
UPDATE wp_posts SET guid = REPLACE(guid, 'ORIGINAL_URL', 'NEW_URL');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'ORIGINAL_URL', 'NEW_URL');
Some good articles:
一些不错的文章:
http://www.wpbeginner.com/wp-tutorials/how-to-create-staging-environment-for-a-wordpress-site/
http://www.wpbeginner.com/wp-tutorials/how-to-create-staging-environment-for-a-wordpress-site/
And:
和:
https://codex.wordpress.org/Moving_WordPress
https://codex.wordpress.org/Moving_WordPress
See Header: Moving Directories On Your Existing Server
请参阅标题:在现有服务器上移动目录
回答by user3208862
I just want to add one thing related to @kreeverp's comment: you should be careful about replacing the GUID value, as the WordPress Codex explains. If you are moving FROM local development TO deployment, then it is safe to change them to the deployment URL. But if you are moving from one URL to another, both of which are deployed (e.g., changing from site.com to site.org) then you do NOT want to replace the GUID value.
我只想添加与@kreeverp 的评论相关的一件事:您应该小心替换 GUID 值,正如WordPress Codex 所解释的那样。如果您要从本地开发转移到部署,那么将它们更改为部署 URL 是安全的。但是,如果您从一个 URL 移动到另一个 URL,并且部署了这两个 URL(例如,从 site.com 更改为 site.org),那么您不想替换 GUID 值。
(I would have left this as a comment to @kreeverp, but I can't do that yet!)
(我会把它留作@kreeverp 的评论,但我还不能这样做!)