Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website and Server Administration Forum


You are currently viewing our Website and Server Administration Forum as a guest. Please register to participate.
Login



Reply
Removing .php file extension file not found!
Old 02-16-2010, 01:24 PM Removing .php file extension file not found!
Junior Talker

Posts: 2
Trades: 0
Hi,

Had a look round the internet for this but cannot really find what I need to know.

My site is made up of PHP pages and to go directly to an inner page the .php needs to be typed onto the end for it to load.

e.g www.domain.com/latestnews.php

I'd like it so that if someone was to type the domain name without the .php, it will load the relevant page.

How do I go about this? I think it can be done via the htaccess file but I'm not sure how!

All advice is much appreciated.
TonUK is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-16-2010, 01:52 PM Re: Removing .php file extension file not found!
ChaibiAlaa's Avatar
Experienced Talker

Posts: 31
Name: Chaibi Mohamed Alaa
Trades: 0
That is named "URL Rewriting", I know a little about it but can't write the full .htaccess code for it, Search on google about URL rewriting you will find your needed result easily and fast.
__________________
CoffeeCupBreak.com |
Please login or register to view this content. Registration is FREE

Blogging-Talk.com |
Please login or register to view this content. Registration is FREE
Community
ChaibiAlaa is offline
Reply With Quote
View Public Profile
 
Old 02-16-2010, 02:09 PM Re: Removing .php file extension file not found!
Junior Talker

Posts: 2
Trades: 0
I found a solution from another forum lol!!


Enter into .htaccess file:

RewriteEngine on
#
## Internally rewrite extensionless file requests to .php files ##
#
# If the requested URI does not contain a period in the final path-part
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
# and if it does not exist as a directory
RewriteCond %{REQUEST_fileNAME} !-d
# and if it does not exist as a file
RewriteCond %{REQUEST_fileNAME} !-f
# then add .php to get the actual filename
RewriteRule (.*) /$1.php [L]
#
#
## Externally redirect clients directly requesting .oho page URIs to extensionless URIs
#
# If client request header contains php file extension
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^.]+\.)+php\ HTTP
# externally redirect to extensionless URI
RewriteRule ^(.+)\.php$ http://www.yourdomain.com/$1 [R=301,L]
TonUK is offline
Reply With Quote
View Public Profile
 
Old 02-21-2010, 08:51 PM Re: Removing .php file extension file not found!
L a r r y's Avatar
Super Talker

Posts: 103
Name: Larry K
Location: Arizona
Trades: 0
One wayto do it is to place each page in its own directory, then set the DirectoryIndex to the name of the php. In the root an .htaccess file needs only a

DirectoryIndex index.php

to accomplish this, if every page on the site is in its own directory and called index.php.

Then www.example.com/index.php can be accessed simply as www.example.com/ and www.example.com/mypage/index.php is accessed as www.example.com/mypage/.
L a r r y is offline
Reply With Quote
View Public Profile Visit L a r r y's homepage!
 
Reply     « Reply to Removing .php file extension file not found!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.66275 seconds with 12 queries