问题
Good morning!
My homepage has the following structure:
/index.php
/pages/de/Home.php
/pages/en/home.php
...
The content is created dynamically with an ?id= The code therefore in index.php is:
<?php
if(isset($_GET[id]) AND isset($dateien[$_GET[id]])) {
include $dateien[$_GET[id]];
} else {
include $dateien[1];
}?>
the array is defined as below. The chosen language is submitted by an ?lang= so a standard link looks like this:
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";
}
I have two navigations - the main navigation and a subnavigation and has the links
Test
Good
For example
The subnavigation is submitted as well by an ? Tag.
...
$submenu[1] = "pages/de/contentleft/standard.php";
$submenu[2] = "pages/de/contentleft/zimmer.php";
On this basis - how can i make my links looking like this:
Www.domain.de/de/test/home.html
Thank you in advance!!!
// edit
Ok, what i have now is:
RewriteEngine On
RewriteRule ^(.+).html$ index.php?id=$1 [L]
Input:
http://example.com/1/2/3.html
Output
http://example.com/index.php?id=1/2/3
Now i would change my structure:
$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];
}
?>
And so on... Is that the right way? Or is there an easier/better one?
//edit 2
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /?lang=$1&subid=$2&id=$3 [L]
来源:https://stackoverflow.com/questions/10631829/mod-rewrite-make-link-readable