Running PHP files without .php extension

Reply

Join Date: Oct 2008
Posts: 20
Reputation: nishant52 is an unknown quantity at this point 
Solved Threads: 0
nishant52 nishant52 is offline Offline
Newbie Poster

Running PHP files without .php extension

 
0
  #1
Nov 28th, 2008
I want to run PHP files without .php extension.

For eg:-

If i open

myhost/docs/default

it should run "default.php".

Please tell me how to implement it.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,145
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 530
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: Running PHP files without .php extension

 
0
  #2
Nov 29th, 2008
what webserver are you using?

just configure it as a default document.
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 24
Reputation: xarz is an unknown quantity at this point 
Solved Threads: 1
xarz's Avatar
xarz xarz is offline Offline
Newbie Poster

Re: Running PHP files without .php extension

 
0
  #3
Nov 29th, 2008
this might be a little bit different from what you want but you can place an index.php file inside myhost/docs/default and place a code index.php which will redirect you to any page that you wish in this case default.php
:: xarz ::
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,145
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 530
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: Running PHP files without .php extension

 
0
  #4
Nov 29th, 2008
or just add default.php to the default document list along with index.php etc...
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 24
Reputation: xarz is an unknown quantity at this point 
Solved Threads: 1
xarz's Avatar
xarz xarz is offline Offline
Newbie Poster

Re: Running PHP files without .php extension

 
0
  #5
Nov 29th, 2008
or use the include("default.php") inside index.php
:: xarz ::
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,444
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 135
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: Running PHP files without .php extension

 
0
  #6
Nov 29th, 2008
Originally Posted by xarz
this might be a little bit different from what you want but you can place an index.php file inside myhost/docs/default and place a code index.php which will redirect you to any page that you wish in this case default.php
Originally Posted by jbennet
or just add default.php to the default document list along with index.php etc...
Originally Posted by xarz
or use the include("default.php") inside index.php
Those sound like pritty patchy solutions to me and why not do what wikipedia does of many people who own a copy of the mediawiki/wikipedia content management system. The way wikipedia does it is by using an apachie httpd.conf file modification to contain 2 rules simular to the following and more about that can be found about half way down the page at
http://www.mediawiki.org/wiki/Manualhort_URL
The link has according to the preview being replaced with a smily so I have also placed the above link in the codebox below:
  1. http://www.mediawiki.org/wiki/Manual:Short_URL

And those rules as they are called are:
  1. Alias /wiki /path/to/your/wiki/index.php
  2. Alias /wiki /var/www/w/index.php
If you wish to edit apachie for faster performance then you may do so with more information at the above link the the prefered method that most people do is using a .htaccess file as it does not require root access. So place at myhost/docs/ a file named '.htaccess' without the quotes and place the following code in it.
  1. RewriteEngine On
  2. RewriteRule ^default$ default.php
There is also a syntax you can use if you are doing this to multiple files. So generally I would use the .htaccess method
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 20
Reputation: nishant52 is an unknown quantity at this point 
Solved Threads: 0
nishant52 nishant52 is offline Offline
Newbie Poster

Re: Running PHP files without .php extension

 
0
  #7
Nov 29th, 2008
Originally Posted by jbennet View Post
what webserver are you using?

just configure it as a default document.
I am using XAMPP for developing my website.

I have set "index.php" as default document but that does not solve my problem

I want to run php files without .php extension.

For eg:-

"myhost/docs/index"

should run "index.php"
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,444
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 135
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: Running PHP files without .php extension

 
1
  #8
Nov 29th, 2008
If you are using Xampp then you will need to enable the rewrite module in the apache httpd.conf file to use the .htaccess files(located C:/xampp/apache/conf/httpd.conf). To do this, first create a copy of the file located C:/xampp/apache/conf/httpd.conf or relative to your installation folder then open the original in notepad. After opening it in notepad, search for the term "LoadModule rewrite_module" without the quotes and when you find it, remove the hash at the beginning of the line. Then search for "AllowOverride None" without the quotes and at least twice will be found and need replacing with "AllowOverride All" (without the quotes). Then save the file and you should be able to use .htacess files. Another set of instructions just reworded of what I have said can be found at http://www.knowledgebase-script.com/...ticle-599.html
You may wonder how I know this, because I also have Xampp. Also when renaming a text file to ".htaccess", you may find that to be impossible to do due to a windows explorer error bug so just open notepad and save the file as ".htaccess" and that will create the file.

Also if it is all files you want to not have the extension use the following code in the .htaccess file.
  1. RewriteEngine On
  2. RewriteRule ^([^.]+)$ $1.php
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 15
Reputation: Bob Arctor is an unknown quantity at this point 
Solved Threads: 1
Bob Arctor Bob Arctor is offline Offline
Newbie Poster

Re: Running PHP files without .php extension

 
1
  #9
Nov 30th, 2008
Give this a whirl -

  1. RewriteEngine On
  2.  
  3. RewriteBase /
  4.  
  5. RewriteRule ^()$ index.php [NC,L]
  6.  
  7. Rewritecond %{REQUEST_URI} !(^/?.*\..*$) [NC]
  8.  
  9. RewriteRule (.*)$ $1.php [NC]
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC