Php files | no extensions


Okay basically what the following peice of code will do is force the apache server to recognise an extensionless file as a .php file. For example, with this code i can create a file called Index instead of index.php
The Index file will still be considered a php file by the server.
Code
# All extension-less files are PHP code
<Files ~ "^[^\.]+$">
ForceType application/x-httpd-php
</Files>


This can also be done with other types of scripts, e.g. javascript, aspx etc.
I think this code only works for Apache servers but im not totally sure. If you dont have an apache server, then try this anyway
ilyas-shezad's Avatar
Views:
1,842
Rating:
Posted on Monday 8th September 2008 at 08:05 PM
UrbanTwitch
UrbanTwitch's Avatar
It's ok. I use: https://www.generateit.net/mod-rewrite/
Posted on Monday 8th September 2008 at 11:34 AM
Dava
Dava's Avatar
copy and paste the following into nopepad

Code
RewriteEngine On
RewriteBase /

# remove .php; use THE_REQUEST to prevent infinite loops
RewriteCond %{THE_REQUEST} ^GET (.*).php HTTP
RewriteRule (.*).php$ $1 [R=301]


# remove index
RewriteRule (.*)/index$ $1/ [R=301]

# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]

# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1.php [L]


and save as .htaccess and upload to your root directory should remove all .php extentions
Posted on Sunday 7th September 2008 at 07:41 PM
UrbanTwitch
UrbanTwitch's Avatar
doesn't work. :
Posted on Saturday 2nd August 2008 at 04:18 AM
Adam981
Adam981's Avatar
haha yeah it does
Posted on Saturday 2nd August 2008 at 02:45 AM
ShadowMage
ShadowMage's Avatar
i think :3
Posted on Saturday 2nd August 2008 at 01:47 AM
UrbanTwitch
UrbanTwitch's Avatar
So to access a file like... soda.php
I could go to:

https://site.com/soda

Right?