views:

28

answers:

2

Possible Duplicate:
How come some site urls do not include a file extension?

Hi there,

I was wondering how I can pass a variable to my PHP script using the following syntax: http://example.com/script?variable=value

It seems I have to include .php after the script name or it won't work, but YouTube for example doesn't have the extension: http://www.youtube.com/watch?v=ql7jGchLAWE

How do I do this?

Thanks in advance!

+1  A: 

Youtube doesn't use PHP.

The way you could do this is by making a directory called script, then calling your script index.php. Then you could do:

http://example.com/script/?variable=value

Alternatively, you could use .htaccess to rewrite your URLs to remove the .php extension.

Skilldrick
I'm pretty sure they do use PHP, I can add the .php extension and view the same page, but any other extension brings up their 404.
Robert
Thank you, I actually tried the index.php trick, but thought it didn't work. Turns out I used $_POST instead of $_GET...
Chris
+1  A: 

You have to make files with no extension executable on your server.

You haven't told us what server software you are running on, so we'd be stabbing in the dark about modifying the configuration.

Thomas O