+ Reply to Thread
Results 1 to 4 of 4
Like Tree2Likes
  • 1 Post By galaxyAbstractor
  • 1 Post By LHVWB

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

  1. #1
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

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

    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!
    dinomirt96 likes this.

  2. #2
    LHVWB's Avatar
    LHVWB is offline Lord Of The Keys LHVWB is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Australia
    Posts
    1,308

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

    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! ;)
    karimirt47 likes this.

  3. #3
    monkey_05_06 is offline x10Hosting Member monkey_05_06 is an unknown quantity at this point
    Join Date
    Dec 2007
    Posts
    16

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

    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 by monkey_05_06; 10-30-2008 at 08:37 PM.

  4. #4
    Dg!Mortal is offline x10Hosting Member Dg!Mortal is an unknown quantity at this point
    Join Date
    Oct 2008
    Posts
    2

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

    nice & helpful, thanks

+ Reply to Thread

Similar Threads

  1. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  2. Sigo con problemas con phpbb2
    By reciecho in forum Soporte
    Replies: 7
    Last Post: 10-20-2007, 06:28 PM
  3. Max php file upload - how to adjust
    By phixer in forum Free Hosting
    Replies: 1
    Last Post: 10-07-2007, 09:15 PM
  4. "PHP Startup: Invalid Library" - Interesting error
    By javaguy78 in forum Free Hosting
    Replies: 5
    Last Post: 03-27-2007, 02:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers