Commit 635819a57e859ecf5880611d2dd9178a6d64a97c

Authored by Geoffrey PREUD'HOMME
1 parent bfaa212b

Fake mod rewrite

Weppes don't want to hear ModRewrite, 404 redirection doesn't work with dynamic JS,
so I had to make those ... things.
.htaccess deleted
... ... @@ -1,4 +0,0 @@
1   -RewriteEngine on
2   -RewriteCond %{REQUEST_URI} !^.+(css|fonts|img|js).+$
3   -RewriteCond %{REQUEST_URI} !\.(ico|jpe?g)$
4   -RewriteRule ^.+$ index.php [L]
5 0 \ No newline at end of file
Makefile
1   -all:
  1 +all: redirs
2 2 cd img; make
  3 +
  4 +redirs:
  5 + for i in $$(cd pages; echo *.php); do echo "<?php require('index.php') // AUTOGEN ?>" > $$i; done
  6 +
3 7 clean:
4 8 cd img; make clean
  9 + for i in *.php; do if grep -q "// AUTOGEN" $$i; then rm -rf $$i; fi; done
... ...
index.php
... ... @@ -8,24 +8,16 @@ $path = $parsedUrl[&#39;path&#39;];
8 8 $explodedUrl = explode('/', $path);
9 9 $page = end($explodedUrl);
10 10  
11   -switch ($page) {
12   - case 'home':
13   - case 'description':
14   - case 'sponsors':
15   - case 'schools':
16   - case 'contact':
17   - $toLoad = $page;
18   - break;
19   - case '':
20   - $toLoad = 'home';
21   - break;
22   - default:
23   - $toLoad = '404';
24   - break;
  11 +if ($page == '') {
  12 + $page = 'home';
25 13 }
26 14  
  15 +$toLoad = "pages/$page.php";
  16 +
  17 +// TODO Test if exists, 404 otherwise
  18 +
27 19 if (isset($_GET['c'])) {
28   - require_once("$toLoad.php");
  20 + require_once("$toLoad");
29 21 } else {
30 22 ?>
31 23 <!DOCTYPE>
... ... @@ -53,7 +45,7 @@ if (isset($_GET[&#39;c&#39;])) {
53 45 <div class="col-md-12 center-block">
54 46 <div class="col-md-12" id="mainContainer">
55 47 <?php
56   - require_once("$toLoad.php");
  48 + require_once("$toLoad");
57 49 ?>
58 50 </div>
59 51 </div>
... ...
contact.php renamed to pages/contact.php
description.php renamed to pages/description.php
home.php renamed to pages/home.php
schools.php renamed to pages/schools.php
sponsors.php renamed to pages/sponsors.php