301 Redirect pointing to a different location - wordpress

I can browse the website https://builtsearch.com.au through browser correctly but when I use cUrl command and use googlebot as the agent I get this.
curl -A 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)' -i https://builtsearch.com.au/
HTTP/1.1 301 Moved Permanently
Date: Wed, 03 Mar 2021 02:24:42 GMT
Server: Apache
X-Powered-By: PHP/7.3.18
X-Frame-Options: SAMEORIGIN
Location: http://www.micaze.com/kategori/izmir-escort/
Content-Length: 0
Content-Type: text/html; charset=UTF-8**
This wrong 301 redirection is stopping googlebot from indexing the website.
The website is using Wordpress.
Any thoughts?

Thanks Tony McCreath. It turns out that my index.php was updated by some malicious plug-in. Sanitizing the index.php seems to resolve the issue.

Related

Nginx : redirect wordpress-like URL from subdirectory to root keeping URL

I tried to look around before posting but I wasn't able to found a solution for my issue.
I used to host a blog in a domain like http://example.com/blog and I moved it to the root /
What I'd like to do is to write a rule in NGINX telling to redirect my old articles from :
http://example.com/blog/my-dope-article
to
http://example.com/my-dope-article
Is there anyway to do that?
Thanks !
I tried this :
rewrite ^/blog/(.*) http://$server_name/$1 permanent;
But it doesn't work because http://example.com/blog/my-dope-article still got rewritten to http://example.com/blog/my-dope-article where I want to delete "/blog" part from the new URL.. :(
Have you looked at the redirects with curl or other tools to examine what exactly happens?
If you're running wordpress on / instead of /blog/ now but haven't yet changed the home- and siteurl-options, WP will create a redirect to the URL it thinks it is running at.
When you look at the headers (e.g. with curl -I http://example.com/ or by using the developer tools in your browser), you'll usually spot differences between redirects caused by nginx and redirects caused by whatever is behind nginx.
For example, a redirect by nginx itself might look like this:
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Tue, 03 Oct 2017 18:37:06 GMT
Content-Type: text/html
Content-Length: 178
Connection: keep-alive
Location: https://www.example.org/
While a redirect from apache/php/WP behind nginx might look like this
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Tue, 03 Oct 2017 18:39:44 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: keep-alive
Location: https://www.example.org/
Vary: Accept-Encoding
Content-Length: 339
Notice the moved Content-Length header, added Vary header and different Content-Type.
And, of course, you can look at the body they send with redirects as well (e.g. curl -v https://www.example.org/).
Example for nginx:
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>
apache/WP
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved here.</p>
<hr>
<address>Apache/2.2.16 (Debian) Server at example.org Port 80</address>
</body></html>
Yes I tried to CURL to see what happened. In the end, I found what I've done wrong: it was the syntax..
So I just put : rewrite ^/blog(.*) /$1 last; at the server directive in my nginx conf file and voilĂ 

HTTP headers return 404 on non-www URL?

I'm doing PHP get_headers() on an mp3 file on my server and receive HTTP 404 when using the non-www address and HTTP 200 when using www.
I can access the file from either address in the browser, so why the 404? Can I fix this somehow with .htaccess?
1) WordPress is configured to use the non-www address (example.com)
2) The files are in the wp-content/uploads area of the WordPress install
3) The www subdomain has a DNS CNAME pointing to the non-www domain (www.example.com -> example.com)
Headers for: http://lhcsj.org/wp-content/uploads/2012/05/2012-5-6-sj.mp3
HTTP/1.1 404 Not Found
Date: Tue, 08 May 2012 21:11:43 GMT
Server: Apache/2.2.3 (CentOS)
Content-Length: 314
Connection: close
Content-Type: text/html; charset=iso-8859-1
Headers for: http://www.lhcsj.org/wp-content/uploads/2012/05/2012-5-6-sj.mp3
HTTP/1.1 200 OK
Date: Tue, 08 May 2012 21:08:05 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Mon, 07 May 2012 17:19:47 GMT
ETag: "9c52430-e3626f-7a1332c0"
Accept-Ranges: bytes
Content-Length: 14901871
Connection: close
Content-Type: audio/mpeg
The fact that www.example.com and example.com point to the same IP address via a DNS CNAME entry doesn't mean that the server is configured to serve both. This server could be configured to handle a multitude of HTTP hosts and the default might not be www.example.com but something else. It would in fact be unsurprising behaviour that it returns a 404 status for a host for which it's not configured (not even a default host).
Check that there is a VirtualHost entry in your Apache Httpd configuration for each of www.example.com and example.com. The fact that Wordpress is configured for a particular host only comes into play after having passed that step.

Firebug Shows 301 Moved Permanently

Im using yii framework with tiny mce. When I run my website in localhost it works just fine. But when I upload to the server the editor doesnt show up. when I check in Firebug, it show :
http://www.ptbm.co.id/veevou/assets/dde67fde/tiny_mce/tiny_mce_gzip.php?s=true&diskcache=true&core=t.......
then the status is 301 moved permanently
This is the request code :
// Send request
x = w.XMLHttpRequest ? new XMLHttpRequest() : get('Msxml2.XMLHTTP') || get('Microsoft.XMLHTTP');
x.overrideMimeType && x.overrideMimeType('text/javascript');
x.open('GET', t.baseURL + '/' + s.page_name + '?' + q, !!cb);
//x.setRequestHeader('Content-Type', 'text/javascript');
x.send('');
The url correctly pointing to existing file.
Anyone have any idea how to fix this? Thanks
Apparently your server redirects to a URL without the www prefix:
$ curl -I 'http://www.ptbm.co.id/veevou/assets/dde67fde/tiny_mce/tiny_mce_gzip.php?s=true&diskcache=true&core=t'
HTTP/1.1 301 Moved Permanently
Date: Fri, 18 Nov 2011 09:14:48 GMT
Server: Apache
X-Powered-By: PHP/5.3.8
X-Pingback: http://ptbm.co.id/xmlrpc.php
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
Pragma: no-cache
Last-Modified: Fri, 18 Nov 2011 09:14:49 GMT
Location: http://ptbm.co.id/veevou/assets/dde67fde/tiny_mce/tiny_mce_gzip.php?s=true&diskcache=true&core=t
Content-Type: text/html; charset=UTF-8
You could remove that RewriteRule, or make sure that t.baseUrl does not have any www prefix.
Without more code it is difficult to give any more exact pointers than that.

Is there any httpresponse header that would redirect user to some page of my site?

I am a server. User sends http requests to me. I wonder if there is some http response header that would tall user web browser to auto rederect to some /my/server/page.html
You can use the Location header with a response code in the 3xx-range.
For an example:
HTTP/1.1 302 Found
Location: /my/server/page.html
301 and 302 HTTP codes can be used to redirect requests, like this:
HTTP/1.1 302 Object moved
Date: Fri, 28 Oct 2011 10:37:34 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Location: http://www.xyz.com/abc

Can 301 and 301 http redirects be cached with an expires header?

I've run a couple tests and cannot get either a 301 or 302 redirect to be cached. In my case I have a large number of avatar icons on a page which I want redirected to a gravatar and/or facebook icon and I want the redirect to be cached, preferably for a medium period say a week.
Example header:
HTTP/1.1 301 Moved Permanently
Date: Sat, 27 Nov 2010 12:13:04 GMT
Server: Apache/2.2.3 (Red Hat)
Location: http://www.gravatar.com/avatar/552e3422df95ab611ce0d8d5b5d66c67?s=50&d=identicon
Cache-Control: max-age=414000
Expires: Thu, 02 Dec 2010 07:13:04 GMT
Content-Length: 330
Content-Type: text/html; charset=iso-8859-1
So is this possible and if so what am I doing wrong?
I understand you intention, but I doubt that browsers are caching 301 status responses (which is confirmed here). Reading your answer you have the HTML-content under your control. Why don't you just change the image-links inside your HTML-response? So instead working with 301 you already "migrate" the links inside the source-document and browser directly hits a 200 link.

Resources