[TUTORIAL]Make the PHP Parser parse PHP inside a file with no extension

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
1.Put "DefaultType application/x-httpd-phpv2" in your .htaccess without quotes.

2. upload the file as no extension (in windows, you need to have the setting "Show filetypes" set to on. And then save the file like flash.txt and rename it to just flash)

Now yo may go to http://yourdomain.tld/flash instead of http://yourdomain.tld/flash.php

NOTE: Make sure you haven't got a folder with the same name!
 

LHVWB

New Member
Messages
1,308
Reaction score
0
Points
0
Nice tutorial, I might actually use this one. ;)

I like that note about the folder, there is always an issue that you can create by mucking around with stuff! ;)
 

monkey_05_06

New Member
Messages
17
Reaction score
0
Points
0
An alternate method to this which 1) allows multiple file types and 2) works if you're trying to access a directory would be to put this in .htaccess instead:

Code:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(([^/]+/+)*[^\.]+)$ $1.php? [QSA]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(([^/]+/+)*[^\.]+)$ $1.html

For example if you type in "http://yoursite.x10hosting.com/somepage" this will first look for "somepage.php" then "somepage.html". If neither is found it will look for the directory named "somepage".

You can add other file-types by simply copying the RewriteCond and RewriteRule lines and changing the extension to the one you want to use.

P.S. The [QSA] (including brackets) tells the server to keep any arguments passed through the address bar, so pages such as "http://yoursite.x10hosting.com/somepage?someVar=27" will work properly. The arguments may be dropped off without it. ;) It must be supplied for any extensions that will use address line arguments.

P.S.S. This works on regular files with the extension in the uploaded file. So leave the ".php" extension on your PHP files, just leave it out of the address. This is especially useful if the extensions you use in your site change, for example if you're upgrading to PHP from HTML but don't want to have to change all your links.
 
Last edited:
Top