Created
December 26, 2012 06:04
-
-
Save anonymous/4378300 to your computer and use it in GitHub Desktop.
PHP: Simple permalinks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase / | |
#If you want any directories ignored uncomment and edit line below | |
#RewriteRule ^(dash|admin)($|/) - [L] | |
RewriteRule ^index\.php$ - [L] | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
#If in sub directory, add before index.php (ex: admin/index.php) | |
RewriteRule . index.php [L] | |
</IfModule> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$pageArray=explode('/',$_SERVER['REQUEST_URI']); | |
//If in sub directory, change to $pageArray[2] etc. | |
switch($pageArray[1]){ | |
case "": | |
include('header.php'); | |
include('home.php'); | |
include('footer.php'); | |
break; | |
case "pageExample": | |
include('header.php'); | |
include('pageExample.php'); | |
include('footer.php'); | |
break; | |
default: | |
include('header.php'); | |
include('404.php'); | |
include('footer.php'); | |
break; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment