This blog is written in two languages, Japanese and English. I am using Language Switcher which generates the hreflang and the language switch in the site. However, this cause that my web server reports the HTTP Status 302 with any pages.
Problem was below.
- Sometimes, the browser redirects to the top page when access to the sitemap.xml.
- The web server always reports HTTP Status 302 Redirect against any pages, even though it exists.
I found this problem with the Google Search Console. It reported that the sitemap.xml was not found and received HTTP Status 302 error.
Check the HTTP Header
Check the HTTP header to confirm.
$ curl -I "https://en.techgaku.com/sitemap.xml"
It exported below.
HTTP/2 302 date: Thu, 03 Dec 2020 13:51:27 GMT server: Apache expires: Thu, 19 Nov 1981 08:52:00 GMT cache-control: no-store, no-cache, must-revalidate pragma: no-cache x-redirect-by: WordPress location: https://en.techgaku.com/ content-type: text/html; charset=UTF-8 set-cookie: PHPSESSID=8287fcaf01f2073684a4550f516b7a1e; path=/ set-cookie: lsw_f96b482c_m=en; path=/ set-cookie: lsw_f96b482c_d=en; path=/
The HTTP Status 302 is actually reported.
How to resolve
I have try and error, finally I found that one of feature of the Language Switcher doesn’t work properly. My web server is not compatible with this feature, and this feature can be disabled.
- Click the “Languages” link in the Word Press Dashboard.
- Open the “Settings” tab.
- Turn off “
- Click “Save Settings” button.
Confirm the problem was fixed
Check the HTTP header.
$ curl -I https://en.techgaku.com/sitemap.xml
It exported below and I confirmed that the problem was fixed, the HTTP Status is now 200.
HTTP/2 200 date: Thu, 03 Dec 2020 14:05:15 GMT server: Apache x-robots-tag: noindex cache-control: max-age=0 expires: Thu, 03 Dec 2020 14:05:15 GMT content-type: text/xml; charset=utf-8 set-cookie: lsw_f96b482c_m=en; path=/ set-cookie: lsw_f96b482c_d=en; path=/
- Representative of RK Kaihatsu. I am a professional developer specializing in macOS Apps, iOS Apps, SDKs and middleware development. I often use ObjC, Swift and C++. Based on development experience, I provide e-learning contents, technical books and technical guidance. I am also a technical seminar instructor, in-house training instructor, and administrative / local goverment staff training instructor.