So I need to put together simple website using php- header and footer will be the same and the middle section changes. I need to be able to click on the link in header and change the section (hem or nyheter, hem is the default). What may be the reasons the following code does not work once I click on link in the header? It loads correctly the first time, but once I click on the link, the header and footer does not load, only the section part opens in a browser. I have htaccess file and header, footer and sections files are on the same level.
Thanks in advance!
<?php
$sections = array("hem", "nyheter");
$sectionTitles = array("HEM", "NYHETER");
$section = "hem";
$content = explode("/", $_SERVER['REQUEST_URI']);
if (!empty($content[2]) && (in_array($content[2], $sections))) { $section = $content[2];}
include ("header.php");
include ("$section.php");
include ("footer.php");
?>
Header code:
<body>
<a href="hem">hem</a> | <a href="nyheter">nyheter</a>
.htaccess:
RewriteEngine On
RewriteCond %{REQUEST_URI} !\.(php|css|js|gif|png|jpe?g|pdf|eot|svg|ttf|woff|ico)$
RewriteRule (.*)$ index.php [L]