all
Comment
2026-01-27 20:21
I was using .htaccess to redirect multilingual content to virtual folders,
I had registered sitemap.xml for each language with Google, but it started throwing errors.
I monitored it for a while, but since it stopped appearing in search results, I took countermeasures.
I moved the configuration from .htaccess to WordPress's function.php and added the following entries:
// Add virtual URLs for language codes
function add_lang_rewrite_rules() {
add_rewrite_rule(
'^(ja|en|ko|cn|tw)/?$',
'index.php?lang=$matches[1]',
'top'
);
'^(ja|en|ko|cn|tw)/(.*)/?$',
'index.php?lang=$matches[1]&pagename=$matches[2]',
}
add_action('init', 'add_lang_rewrite_rules');
// Add lang to query variables
function add_lang_query_var($vars) {
$vars[] = 'lang';
return $vars;
add_filter('query_vars', 'add_lang_query_var');
function get_current_lang() {
$lang = get_query_var('lang');
if (!$lang) {
return 'ja'; // Default language
return $lang;
add_action('template_redirect', function() {
if (is_admin()) return;
$request_uri = trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/');
// Exclude sitemap.xml, robots.txt, CSS/JS/images, etc.
if (preg_match('/.(xml|txt|css|js|png|jpg|jpeg|gif)$/i', $request_uri)) {
return;
// Redirect only the top page / to /ja/
if ($request_uri === '' || $request_uri === 'index.php') {
wp_redirect(home_url('/ja/'), 301);
exit;
});
We'll continue monitoring the situation for a while longer.
We are using the site below for our sitemap
Create Sitemap - Automatic Generation Tool "sitemap.xml Editor"
next
<< Back to list
TOP
Top Page
Sample page 1
Sample page 2
Sample page 3
Old Page
News
RECORDS
MEMO
NOTE w/ PHOTO
Work
Profile
Contact
Estimate Simulator
Privacy Policy
MEMOMEMO
About Fixing Errors in Google Search Console
2026-01-27 20:21
TOP
Top Page
Sample page 1
Sample page 2
Sample page 3
Old Page
News
RECORDS
MEMO
NOTE w/ PHOTO
Work
Profile
Contact
Estimate Simulator
Privacy Policy