开发者

What other get method characters can be used? aside from question mark?

开发者 https://www.devze.com 2023-02-24 04:47 出处:网络
the normal get: http://localhost/get.php?id=2&get=row can it be done like this? http://localhost/get.php&id=2&get=row

the normal get: http://localhost/get.php?id=2&get=row

can it be done like this?

http://localhost/get.php&id=2&get=row

or in other way.

When a user make a parameter to my site like

http://test.com/?url=http://loca开发者_JAVA技巧lhost/sample/

or what if it contains a "?id=234"

so the new url is http://test.com/?url=http://localhost/smaple?id=1234

it creates now a 2 question mark.


What you want to do is not possible, at least not using & and ? as separator characters. They have a defined meaning in a URL and cannot be used beyond that meaning. Repeating the characters will result in an invalid URL. It will probably work in most browsers but it's bad practice.

Consider sticking with the classical ?param=value&param2=value2 notation. Why do you want to change that in the first place? Is there a specific reason?

If you really want to do this, and are fine with some other character to separate the parameters from each other, you can use one of these two methods.

PATH_INFO

If the AcceptPathInfo setting is enabled on your Apache server (it usually is), you can address your URL like this:

http://localhost/get.php/id=2/get=row

this will call get.php. The id=2/get=row part will be available in the $_SERVER["PATH_INFO"] variable for you to split.

mod_rewrite

Alternatively, you could use mod_rewrite to map a URL according to a pre-defined pattern, like this:

http://localhost/2/row

Here is a question dealing with how to use mod_rewrite; there are many more on Stack Overflow.


When a user make a parameter to your site, he has to urlencode such data, so, it's going to be

http://test.com/?url=http%3A%2F%2Flocalhost%2Fsmaple%3Fid%3D1234


You can always use URLRewriting if you are not a fan of having get variables in your URL but in response to you question the ? is part of the standard

if using apache user RewriteRule in .htaccess

0

精彩评论

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

关注公众号