本地站点重定向到线上。

huangapple go评论67阅读模式
英文:

Local site redirects to live

问题

My LocalWP staging website keeps redirecting me to the live web + cant even log into the wp admin.
This is a custom wordpress website. I’m using LocalWP, made a copy of the website using duplicator.

How could I fix this error? Has anyone had familiar issues?
Thank you

I browsed the files but couldnt really find anything that could help.

我的LocalWP暂存网站不断重定向到实际网站,甚至无法登录到wp管理界面。
这是一个定制的WordPress网站。我正在使用LocalWP,使用复制工具复制了网站。

我该如何解决这个错误?有人遇到过类似问题吗?
谢谢

我浏览了文件,但没有找到能够帮助的内容。

英文:

My LocalWP staging website keeps redirecting me to the live web + cant even log into the wp admin.
This is a custom wordpress website. I’m using LocalWP, made a copy of the website using duplicator.

How could I fix this error? Has anyone had familiar issues?
Thank you

I browsed the files but couldnt really find anything that could help

答案1

得分: 2

最好的方法是在数据库中更改站点URL。转到表wp_options,找到option_name等于siteurl的行,然后将其更改为您的本地站点URL(通常为http://localhost),对home行进行相同的更改。

否则,如果您无法在数据库中更改URL,可以将设置放入配置文件中,但要小心,如果将文件上传到生产服务器,它将停止工作。将以下两行放入您的wp-config.php中:

define('WP_HOME', 'http://localhost');
define('WP_SITEURL', 'http://localhost');
英文:

There are at least two options:

The best way is to change site URL in database. Go to table wp_options and find a row with option_name equals to siteurl than change it to your local site URL (it's often be http://localhost), make same changes to home row.

Else, if you can't change the URL in the DB, there is an option to put the setting into config file, but be careful, if you upload the file to the live server, it will stop working. Put these two lines into your wp-config.php:

define( 'WP_HOME', 'http://localhost' );
define( 'WP_SITEURL', 'http://localhost' );

答案2

得分: 1

以下是翻译好的部分:

Had this issue before.

The best way to start is by going through a basic check list of things to check.

  1. If you have cpanel access. Go to your database, and click on the wp_options tables. Once there, if you go to option_id for siteurl and enter your local host / local site url details here. You'll also need to go to option_id for home, and enter your local sites home page url. If you've copied or installed a backup of your live site, these details will have your live sites details to start with, and will cause your local site to redirect to your live site, until these details are changed to your local host /local sites url details.

You'll also want to go through other option_id's, like the uploads path, as you'll need to set the correct url for this to, if your going to be uploading images.

You'll also want to make sure that your .htaccess file is correct as well, as this is normally the other main one, that can cause your local site redirecting to the live site.

This may help if you want a basic .htaccess file for your local wordpress site to get you going:


RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /public_html/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /public_html/index.php [L]

Please note this .htaccess file will only work if your wordpress root directory is under the public_html folder.

英文:

Had this issue before.

The best way to start is by going through a basic check list of things to check.

  1. If you have cpanel access. Go to your database, and click on the wp_options tables. Once there, if you go to option_id for siteurl and enter your local host / local site url details here. You'll also need to go to option_id for home, and enter your local sites home page url. If you've copied or installed a backup of your live site, these details will have your live sites details to start with, and will cause your local site to redirect to your live site, until these details are changed to your local host /local sites url details.

You'll also want to go through other option_id's, like the uploads path, as you'll need to set the correct url for this to, if your going to be uploading images.

You'll also want to make sure that your .htaccess file is correct as well, as this is normally the other main one, that can cause your local site redirecting to the live site.

This may help if you want a basic .htaccess file for your local wordpress site to get you going:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /public_html/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /public_html/index.php [L]
</IfModule>

Please note this .htaccess file will only work if your wordpress root directory is under the public_html folder.

答案3

得分: 0

将 WordPress 数据库中的 wp_options 表的 siteurl 和 home 行更新为您的暂存 URL。

验证一下您的 WordPress 安装根目录中的 wp-config.php 文件是否包含任何硬编码的参考 live website 的 URL。

查找类似于 define('WP_HOME', 'http://www.istacksolution.com'); 或 define('WP_SITEURL', 'http://www.istacksolution.com'); 的行,并将其更新为您的暂存 URL。

英文:

WordPress database and update the wp_options table's siteurl and home rows to your staging URL.

Verify that your wp-config.php file in the root directory of your WordPress installation doesn't contain any hard-coded references to the live website's URL.

Look for lines like define('WP_HOME', 'http://www.istacksolution.com'); or define('WP_SITEURL', 'http://www.istacksolution.com'); and update them with your staging URL.

huangapple
  • 本文由 发表于 2023年5月29日 16:21:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76355724.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定