使用php和.htaccess的多语言站点的友好URL

时间:2019-05-18 12:07:22

标签: php .htaccess seo

我已经按照以下规则使用PHP和.htaccess编写了多语言站点系统

在.htaccess文件中,我的代码是:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

在我的 index.php 文件中,我的代码是:

$lang_code=$request_uri[1];
$page_code=$request_uri[2];

// default lang and page
if ( !$lang_code ) $lang_code='en';
if ( !$page_code) $page_code='home-page';

// custom constans for choosen language
include('_langs/'.$lang_code.'/'.$page_code.'.php');

// common HTML and PHP code for site
include($page_code.'/content.php'); ?>

我的站点文件内容为:

_langs/de/contact.php
_langs/de/home-page.php
_langs/en/contact.php
_langs/en/home-page.php
home-page/content.php
contact/content.php
index.php

我对Google的站点地图是:

example.com/
example.com/de/home-page/
example.com/de/contact/
example.com/en/home-page/
example.com/en/contact/

可以,但是Google Search Console表示:已排除 该页面在“状态”标签中包含重定向。 Google搜索引擎的多语言架构是另一种/更好的方法吗?

0 个答案:

没有答案
相关问题