How do I pass variables using 'file?x=3' instead of 'file.php?x=3'? [duplicate]
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 examp开发者_运维百科le doesn't have the extension: http://www.youtube.com/watch?v=ql7jGchLAWE
How do I do this?
Thanks in advance!
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.
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.
精彩评论