Forgot Password / Register
Site Statistics
Total Members: 507
Total Tutorials: 242
Newsest User: Rivas1322
Todays Unique Hits: 89
0 Users 2 Guests Online

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
Views:
1155
Rating:
Posted on Monday 8th September 2008 at 08:05 PM
UrbanTwitch
UrbanTwitch
It's ok. I use: http://www.generateit.net/mod-rewrite/
Posted on Monday 8th September 2008 at 11:34 AM
Dava
Dava
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
doesn't work. :
Posted on Saturday 2nd August 2008 at 04:18 AM
Adam981
Adam981
haha yeah it does
Posted on Saturday 2nd August 2008 at 02:45 AM
ShadowMage
ShadowMage
i think :3
Posted on Saturday 2nd August 2008 at 01:47 AM
UrbanTwitch
UrbanTwitch
So to access a file like... soda.php
I could go to:

http://site.com/soda

Right?