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

Recommended Answers

All 3 Replies

You can do this very easily with Apache.

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

<Files index>
ForceType application/x-httpd-php
</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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.