| | |
How to hide .php extension
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2007
Posts: 26
Reputation:
Solved Threads: 0
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
(...or is there a way to tell if the site is in fact still running Ruby on Rails??)
Thank you
Mark
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!
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
•
•
Join Date: May 2006
Posts: 45
Reputation:
Solved Threads: 0
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
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.
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
PHP Syntax (Toggle Plain Text)
<Files index> ForceType application/x-httpd-php </Files>
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.
![]() |
Similar Threads
- Open In New Window Php (PHP)
- changing the .php extension and Apache mod_rewrite question (PHP)
- how to protect webpage (PHP)
- Help in PHP extension (PHP)
- Newbie Question - Hiding php extension (PHP)
- PHP & File Extensions (PHP)
- php help needed for login (PHP)
- Php parser error when xml version is mentioned (PHP)
- Using Search Engine Friendly PHP URLs (PHP)
Other Threads in the PHP Forum
- Previous Thread: Adding x amount of days to a specific date?
- Next Thread: Listbox is not displaying the correct information if at all
| Thread Tools | Search this Thread |
# 5.2.10 alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions simple sms sockets source space spam sql syntax system table tutorial update upload url validator variable video web youtube






