I'm currently been trying to figure out how to remove .php
extension from URL bar. However when I remove .php
it gives me a blank white page.
Could someone please be able to explain why this would be happening?
I've added to the php.ini
: expose_php=Off
and also got this in my .htaccess
:
# Return 404 if original request is /foo/bar.php
RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]
Then started to write the following for URL
:
<?php
function parseCurrentURL() {
$pageURL = 'http';
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
if(parse_url(parseCurrentURL(), PHP_URL_PATH)){
$url = parse_url(parseCurrentURL(), PHP_URL_PATH);
switch(substr($url, strrpos($url, '/') + 1)){
case 'forums':
break;
}
}
?>
Example with .php
:
Example without .php
: