How to hide .php extension

Reply

Join Date: May 2007
Posts: 26
Reputation: markchicobaby is an unknown quantity at this point 
Solved Threads: 0
markchicobaby markchicobaby is offline Offline
Light Poster

How to hide .php extension

 
0
  #1
Nov 8th, 2007
Hi I've been looking at site www.cdbaby.com, apparently they switched over from Ruby on Rails to PHP. I would like to know if anyone can explain how come none of the links have a "php" extension on them, and how this can be achieved?

(...or is there a way to tell if the site is in fact still running Ruby on Rails??)

Thank you
Mark
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Solved Threads: 35
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: How to hide .php extension

 
0
  #2
Nov 8th, 2007
You can do this very easily with Apache.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 45
Reputation: petzoldt01 is an unknown quantity at this point 
Solved Threads: 0
petzoldt01 petzoldt01 is offline Offline
Light Poster

Re: How to hide .php extension

 
0
  #3
Nov 8th, 2007
I have actually just been working on something similar myself. My post is here . My thread was pretty long, but scroll down to the bottom for some links to check out.

There are many ways to accomplish what CDBaby did.
You can put an extensionless PHP script into any directory and then configure apache to open it as a PHP file. So, for this setup...

/webroot
/webroot/index <-- This is the PHP file
/webroot/.htaccess
/webroot/whatever-else-you-need

You can use this in your .htaccess
  1. <Files index>
  2. ForceType application/x-httpd-php
  3. </Files>
Now, a URL such as this, http://www.yoursite.com/index/cd/elton-john, will end up calling your PHP script and ignoring the rest of the URL. You will then have to analyze the rest of the URL, '/cd/elton-john', in your PHP script, and take action accordingly.
Note: the directory /cd/elton-john' does not have to exist.

This method avoids any complicated apache configurations. But if you need a more complex setup, you may want to check out using the apache module 'mod_rewrite'. If you know how to use Perl Regular Expressions, you can take complete control over what happens to the URLs, manipulate, rewrite, redirect, whatever.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 271
Reputation: fatihpiristine has a little shameless behaviour in the past 
Solved Threads: 16
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: How to hide .php extension

 
0
  #4
Nov 8th, 2007
answer is here already if u wanna use .htaccess

http://www.daniweb.com/forums/thread95909.html
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC