Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we use & in url?

Tags:

url

uri

Can we use "&" in a url ? or should "and" be used?

like image 324
Jitendra Vyas Avatar asked Nov 07 '09 16:11

Jitendra Vyas


People also ask

Has CSS selector can I use?

Presently, the CSS :has() selector is not widely supported by browsers; this selector only works in the latest version of Safari or via the experimental features flag in the latest version of Chrome. So for now, we must not use :has() in production.

Is Flexbox supported by all browsers?

Flexbox is very well supported across modern browsers, however there are a few issues that you might run into. In this guide we will look at how well flexbox is supported in browsers, and look at some potential issues, resources and methods for creating workarounds and fallbacks.


2 Answers

Yes, you can use it plain in your URL path like this:

http://example.com/Alice&Bob

Only if you want to use it in the query you need to encode it with %26:

http://example.com/?arg=Alice%26Bob

Otherwise it would be interpreted as argument separator when interpreted as application/x-www-form-urlencoded.

See RFC 3986 for more details.

like image 181
Gumbo Avatar answered Oct 26 '22 19:10

Gumbo


An URL is generally in the form

scheme://host/some/path/to/file?query1=value&query2=value

So it is not advisable to use it in an URL unless you want to use it for parameters. Otherwise you should percent escape it using %26, e.g.

http://www.example.com/hello%26world

This results in the path being submitted as hello&world. There are other characters which must be escaped when used out of context in an URL. See here for a list.

like image 30
Alfonso Avatar answered Oct 26 '22 18:10

Alfonso