Skip to content

Instantly share code, notes, and snippets.

@davidkevork
Last active September 5, 2016 14:33
Show Gist options
  • Save davidkevork/9f0df738c603f9cb094b to your computer and use it in GitHub Desktop.
Save davidkevork/9f0df738c603f9cb094b to your computer and use it in GitHub Desktop.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
Options +FollowSymLinks
RewriteEngine On
# Handle Front Controller...
RewriteCond %{REQUEST_URI} !^.*\.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php
</IfModule>
<?php
// The MIT License (MIT)
// Copyright (c) 2015 David Kevork
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
/*
| https://www.facebook.com/david.kevork
| https://github.com/davidkevork
| https://twitter.com/david04775877
| https://www.hackerearth.com/users/david.kevork/
| https://plus.google.com/u/0/105107520672402068027
| http://www.davidkevork.gq/
*/
function capture() {
$protocol = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? 'https://' : 'http://';
$REQUEST_URI = explode("?", $_SERVER['REQUEST_URI']);
$data = explode(".", $REQUEST_URI[0]);
if (sizeof($data) > 1) // no extension
{
$ext = $data[count($data)-1];
if ($ext == "php") {
$DomainName = $protocol.$_SERVER['SERVER_NAME'];
$FileName = $data[0];
for ($i = 1; $i < sizeof($data)-1; $i++) {
$FileName .= '.'.$data[$i];
}
$Param = '';
if (isset($REQUEST_URI[1])) {
$Param = '?'.$REQUEST_URI[1];
}
$Location = $DomainName.$FileName.$Param;
header("Location: $Location");
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment