Options +MultiViews -Indexes +FollowSymLinks
RewriteEngine On
RewriteBase /
DirectorySlash Off

# rewrite /dir/file?query to /dir/file.php?query
RewriteRule ^([\w\/-]+)(\?.*)?$ $1.php$2 [L,T=application/x-httpd-php]


## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=301,L]


# remove trailing slash
RewriteRule ^(.*)\/(\?.*)?$ $1$2 [R=302,L]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\\.php [L]

# To internally redirect /dir/foo.php to /dir/foo
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

#Redirect url with php extention to page not found
#nt wkng
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^(.+)$ https://rocketta.io/404 [NC,QSA]


#Show page not found for directory access
RewriteCond %{REQUEST_FILENAME} !-f
# the above ignores any url for a file that exists on the site
RewriteCond %{REQUEST_FILENAME} -d
# the above ignores any url for a directory that exists on the site
RewriteRule ^(.+)$ https://rocketta.io/404 [NC,QSA]
