Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Index.php?id=
Bladeq123
post
Post #1





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 25.12.2008

Ostrzeżenie: (0%)
-----


Witam, mam pytanie jak zrobić że jak wejdę na stronę to żeby czytało od razu np. index.php?id=news
a nie sam index.php

Ten post edytował Bladeq123 8.01.2009, 21:06:56
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Strarus
post
Post #2





Grupa: Zarejestrowani
Postów: 339
Pomógł: 12
Dołączył: 22.11.2008

Ostrzeżenie: (20%)
X----


W head na index.php, a tamto tam gdzie mają się includować strony (1.inc.php 2.inc.php itd.)

index.php
Kod
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
<head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
      <meta name="robots" content="index" />
      <meta name="description" content="Tytuł strony" />
      <meta name="keywords" content="Słowa kluczowe" />
      <link rel="shortcut icon" href="favicon.ico" />
      <link rel="stylesheet" type="text/css" href="style.css" />
      <title>Untitled</title>
      <?php
header("Location: index.php?site=news");
?>
</head>

<body>
<p>


</p>
</body>
</html>


indeks.inc.php
Kod
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
<head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
      <meta name="robots" content="index" />
      <meta name="description" content="Tytuł strony" />
      <meta name="keywords" content="Słowa kluczowe" />
      <link rel="shortcut icon" href="favicon.ico" />
      <link rel="stylesheet" type="text/css" href="style.css" />
      <title>Untitled</title>
</head>

<body>
<?php
if(isset($_GET[ 'site' ])){
$site = htmlspecialchars($_GET['site']) .'.inc.php';
if(file_exists($site )){
include( $site );
}else{
echo 'Strona o podanym adresie nie istnieje.';  // jeśli nie ma strony inaczej 404
}
}else{
echo 'Strona główna'; //Domyślnie nie jest index.php?as=asd ale pokazuje sie coś
}
?>
</body>
</html>


U mnie to jest tak rozwiązane (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

pozdro

Ten post edytował Strarus 8.01.2009, 21:31:03
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 29.12.2025 - 12:52