Created
March 12, 2016 13:05
-
-
Save Hexodus/144de06fde12a09c005d to your computer and use it in GitHub Desktop.
Rewrites all url requests to index.php and stores the path in the url variable which is being processed into $uri variable (to prevent empty values).
This file contains 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
//.htaccess code | |
RewriteEngine On | |
RewriteBase / | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA] | |
//PHP part | |
// extracts the path from url and stores it in $uri | |
if (isset($_GET["url"])) | |
$uri = substr_count($_GET["url"], "/") >=1 ? explode("/", $_GET["url")) : $_GET["url"]; | |
else | |
$uri = "/"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment