RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 484 | Replies: 8 | Thread Tools  Display Modes
Reply
Join Date: Oct 2008
Posts: 13
Reputation: nishant52 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
nishant52 nishant52 is offline Offline
Newbie Poster

Running PHP files without .php extension

  #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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2005
Location: Dundee, Scotland
Posts: 13,954
Reputation: jbennet is just really nice jbennet is just really nice jbennet is just really nice jbennet is just really nice jbennet is just really nice 
Rep Power: 35
Solved Threads: 367
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: Running PHP files without .php extension

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

just configure it as a default document.
TRY MY SUGGESTIONS AT YOUR OWN RISK

Master of puppets Im pulling your strings, blinded by me, you cant see a thing. Master! Master!
Reply With Quote  
Join Date: Nov 2008
Location: Dumaguete, Philippines
Posts: 24
Reputation: xarz is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
xarz's Avatar
xarz xarz is offline Offline
Newbie Poster

Re: Running PHP files without .php extension

  #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  
Join Date: Apr 2005
Location: Dundee, Scotland
Posts: 13,954
Reputation: jbennet is just really nice jbennet is just really nice jbennet is just really nice jbennet is just really nice jbennet is just really nice 
Rep Power: 35
Solved Threads: 367
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: Running PHP files without .php extension

  #4  
Nov 29th, 2008
or just add default.php to the default document list along with index.php etc...
TRY MY SUGGESTIONS AT YOUR OWN RISK

Master of puppets Im pulling your strings, blinded by me, you cant see a thing. Master! Master!
Reply With Quote  
Join Date: Nov 2008
Location: Dumaguete, Philippines
Posts: 24
Reputation: xarz is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
xarz's Avatar
xarz xarz is offline Offline
Newbie Poster

Re: Running PHP files without .php extension

  #5  
Nov 29th, 2008
or use the include("default.php") inside index.php
:: xarz ::
Reply With Quote  
Join Date: Sep 2007
Posts: 177
Reputation: cwarn23 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 20
cwarn23 cwarn23 is offline Offline
Junior Poster

Re: Running PHP files without .php extension

  #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:
http://www.mediawiki.org/wiki/Manual:Short_URL

And those rules as they are called are:
Alias /wiki /path/to/your/wiki/index.php
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.
RewriteEngine On
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
Signature note:
Do not edit the registry just because someone on the forum says so. Do some research on the internet before editing the registry.
Reply With Quote  
Join Date: Oct 2008
Posts: 13
Reputation: nishant52 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
nishant52 nishant52 is offline Offline
Newbie Poster

Re: Running PHP files without .php extension

  #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  
Join Date: Sep 2007
Posts: 177
Reputation: cwarn23 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 20
cwarn23 cwarn23 is offline Offline
Junior Poster

Re: Running PHP files without .php extension

  #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.
RewriteEngine On
RewriteRule ^([^.]+)$ $1.php
Signature note:
Do not edit the registry just because someone on the forum says so. Do some research on the internet before editing the registry.
Reply With Quote  
Join Date: Nov 2008
Posts: 5
Reputation: Bob Arctor is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Bob Arctor Bob Arctor is offline Offline
Newbie Poster

Re: Running PHP files without .php extension

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

RewriteEngine On

RewriteBase /

RewriteRule ^()$ index.php [NC,L]

Rewritecond %{REQUEST_URI} !(^/?.*\..*$) [NC]

RewriteRule (.*)$ $1.php [NC]
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the PHP Forum
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 9:08 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC