最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

How to prevent redirect 301

matteradmin7PV0评论

I'm encountering a 301 problem from my pre-production site which is automatically redirected to my production site. I know the problem comes from WP because I already launched a curl in order to see responses either :

1) targeting the WP pre-production-site :

> GET / HTTP/1.1
> Host: www.pre-production-site
> User-Agent: curl/7.53.1
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Date: Tue, 07 Mar 2017 11:51:19 GMT
< Server: Apache/2.2.22
< Location: /
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: sameorigin
< Vary: Accept-Encoding
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8
<
* Connection #0 to host www.pre-production-site left intact

2) targeting my own .php file uploaded on the pre-production-site :

> GET /up.php HTTP/1.1
> Host: www.pre-production-site
> User-Agent: curl/7.53.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Tue, 07 Mar 2017 11:54:29 GMT
< Server: Apache/2.2.22
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: sameorigin
< Vary: Accept-Encoding
< Content-Length: 2
< Content-Type: text/html; charset=UTF-8
<
42* Connection #0 to host www.pre-production-site left intact

I don't understand because I've already checked :

  • .htaccess file : doesn't contain any kind of redirection
  • Apache configuration files : seems OK too
  • source code (if a plugin would sets a Location: header) with a recursive grep : didn't find anything

Where is set this 301 ? I'm not sure if I left all informations that you need so feel free to ask me !

Thank you very much for your help !

I'm encountering a 301 problem from my pre-production site which is automatically redirected to my production site. I know the problem comes from WP because I already launched a curl in order to see responses either :

1) targeting the WP pre-production-site :

> GET / HTTP/1.1
> Host: www.pre-production-site
> User-Agent: curl/7.53.1
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Date: Tue, 07 Mar 2017 11:51:19 GMT
< Server: Apache/2.2.22
< Location: http://www.production-site/
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: sameorigin
< Vary: Accept-Encoding
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8
<
* Connection #0 to host www.pre-production-site left intact

2) targeting my own .php file uploaded on the pre-production-site :

> GET /up.php HTTP/1.1
> Host: www.pre-production-site
> User-Agent: curl/7.53.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Tue, 07 Mar 2017 11:54:29 GMT
< Server: Apache/2.2.22
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: sameorigin
< Vary: Accept-Encoding
< Content-Length: 2
< Content-Type: text/html; charset=UTF-8
<
42* Connection #0 to host www.pre-production-site left intact

I don't understand because I've already checked :

  • .htaccess file : doesn't contain any kind of redirection
  • Apache configuration files : seems OK too
  • source code (if a plugin would sets a Location: header) with a recursive grep : didn't find anything

Where is set this 301 ? I'm not sure if I left all informations that you need so feel free to ask me !

Thank you very much for your help !

Share Improve this question edited Mar 7, 2017 at 15:36 Fred Sautot asked Mar 7, 2017 at 13:01 Fred SautotFred Sautot 13 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

Did you check the 'options' table in your WP databasse for the two instances of the domain name (something like 'http://www.example ' ).

Not clear if your pre-production site is hosted on a local machine, or networked server. Might be some firewall redirection rules causing issues.

Just a little clarification of @RickHellewell's answer:

To prevent Wordpress from redirecting to my live site when I copied the database to my local machine for development work, I updated two rows in the database with the following query:

UPDATE wp_options SET option_value='http://localhost' WHERE option_value='http://mylivesite';

This allowed me to load (and work on) my site locally by visiting http://localhost and http://localhost/wp-admin

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far