views:

130

answers:

1

YouTube has URL's like these:

http://www.youtube.com/watch?v=zKqeCtjFGFc

When I create a PHP page mine would be like these:

watch.php?v=zKqeCtjFGFc

How does YT hide the PHP extension, and I know YT is probably written in Python or something other than PHP but I have seen this done in WordPress and other PHP written apps.

Can this be done without using htacess rewrites?

+8  A: 

The easiest is to have a directory named watch, and have an index.php file inside that directory. Then /watch would serve the index.php file and by extension your index.php script would get the query parameter v.

A more robust yet complicated way to do it is to use mod_rewrite to rewrite /watch.php to /watch

I haven't tested but a rule like this might do the trick, you'd put this code in your .htaccess file

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/watch$
RewriteRule ^/watch$ watch.php
macinjosh
Thanks, the index.php trick is neat, didn't think of that :)
James