早上好!
我的主页有以下结构:
/index.php
/pages/de/Home.php
/pages/en/home.php
...
使用?id =动态创建内容 因此index.php中的代码是:
<?php
if(isset($_GET[id]) AND isset($dateien[$_GET[id]])) {
include $dateien[$_GET[id]];
} else {
include $dateien[1];
}?>
数组的定义如下。所选语言由?lang =提交 所以标准链接如下所示:
Index.php?id=1&lang&=1
$dateien = array();
if ($lang==1) {
$dateien[1] = "pages/de/home.php";
$dateien[3] = "pages/de/restaurant.php";
} else {
$dateien[1] = "pages/en/home.php";
$dateien[3] = "pages/en/restaurant.php";
}
我有两个导航 - 主导航和子导航,并有链接
Test
Good
例如
子导航也是由?提交的?标签
...
$submenu[1] = "pages/de/contentleft/standard.php";
$submenu[2] = "pages/de/contentleft/zimmer.php";
在此基础上 - 我怎样才能使我的链接看起来像这样:
Www.domain.de/de/test/home.html
提前谢谢!!!
//编辑
好的,我现在拥有的是:
RewriteEngine On
RewriteRule ^(.+).html$ index.php?id=$1 [L]
输入:
http://example.com/1/2/3.html
输出
http://example.com/index.php?id=1/2/3
现在我要改变我的结构:
$dateien = array();
$dateien['home'] = "pages/de/home.php";
$dateien['restaurant'] = "pages/de/restaurant.php";
的index.php
$array = explode('/',$_GET['id']);
$id = $array[0];
$lang = $array[1];
$menu = $array[2];
if(isset($id) AND isset($dateien[$id])) {
include $dateien[$id];
} else {
include $dateien[1];
}
?>
等等......这是正确的方法吗?或者是否更容易/更好?
//编辑2
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /?lang=$1&subid=$2&id=$3 [L]