开发者

How do I pass variables using 'file?x=3' instead of 'file.php?x=3'? [duplicate]

This question already has answers here: Closed 12 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜