Current location: Hot Scripts Forums » Programming Languages » PHP » php files with no extension?


php files with no extension?

Reply
  #1 (permalink)  
Old 08-31-05, 07:18 AM
liljoeyjordison liljoeyjordison is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
php files with no extension?

Hi,
I know you can use htaccess to allow files with any extension like .news to work like a php file, but can this be done for files with no extension? For example have a file called www.domain.com/myfile and that work like a php script. This is because I am having trouble creating directories, and as I would only want one file in each directory this seems to be a much simpler way of doing things.

If this is impossible could I use htaccess to set up a redirect for anyone trying to view domain.com/myfile gets moved to domain.com/files/myfile.php or something along those lines?

The first solution is preferable, but any help on this matter would be greatly appreciated.

Much love,
Lil'j
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 08-31-05, 08:53 AM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
Upload a .htaccess file that looks like this:
Code:
<Files />
ForceType application/x-httpd-php
</Files>

RewriteEngine on
RewriteBase /

RewriteRule ^.htaccess$ - [F]

RewriteRule ^([A-z,0-9,_,-]+)/?$              $1.php     [QSA]
RewriteRule ^([A-z,0-9,_,-]+)/index\.html$    $1.php     [QSA]
That way, domain.com/whatever, domain.com/whatever/, and domain.com/whatever/index.html will load domain.com/whatever.php. The directory or filename can include upper and lower case alphanumeric characters, underscores, and hyphens.

Last edited by Keith; 08-31-05 at 08:57 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 09-01-05, 04:29 AM
liljoeyjordison liljoeyjordison is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
So does that mean that domain.com/foo/ will load foo.php and domain.com/blah/ will load blah.php ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 09-01-05, 04:35 AM
liljoeyjordison liljoeyjordison is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by liljoeyjordison
So does that mean that domain.com/foo/ will load foo.php and domain.com/blah/ will load blah.php ?
I keep recieving 403 Forbidden errors... help?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 09-03-05, 02:46 PM
Christian's Avatar
Christian Christian is offline
Community VIP
 
Join Date: Mar 2005
Location: ProgrammingTalk
Posts: 2,449
Thanks: 0
Thanked 6 Times in 5 Posts

Last edited by Christian; 09-03-05 at 02:55 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP multi-dimensional array sorting issue aqw PHP 2 06-25-05 12:09 AM
How to Make my Php output write static Html files cebuy PHP 1 02-04-05 06:52 AM
move files around an ftp server, with php file upload script? wapchimp PHP 2 12-19-04 08:27 AM
PHP Runner , Preview PHP files ! moslehi@gmail.com General Advertisements 3 12-08-04 04:01 PM
php files in a cgi-bin directory epic1231 PHP 7 12-31-03 04:42 PM


All times are GMT -5. The time now is 10:23 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.