Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a URL that contains an ampersand & with start command?

I already know that to open a webpage with the default browser you use: start www.google.com. However, I'm trying to open a URL that contains a '&' in it for example:

https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world

If I use:

start https://www.google.dz/?gws_rd=cr,ssl&ei=rXc_WYq3Msy2abGXpugH#safe=off&q=hello+world

It will not work because there is a &

like image 518
idris_djoudi Avatar asked Jun 13 '17 05:06

idris_djoudi


People also ask

How do you handle an ampersand in a URL?

For example, to encode a URL with an ampersand character, use %24. However, in HTML, use either & or &, both of which would write out the ampersand in the HTML page.

How do you pass ampersand in query string?

Replace ampersands with “&” Replacing the ampersand characters with encoded equivalents does not change the functionality of the query string, but it does produce completely valid code.

How do I open a URL without a browser?

You can use the HH command to open any website. Though it will not open the website in the browser, but this will open the website in an HTML help window. works great to just hit a website to log an IP or kick off a script.


2 Answers

& is a special character in bash, so if the URL contains a special character you just have to do it like this:

start "" "your url" 
like image 117
idris_djoudi Avatar answered Oct 20 '22 04:10

idris_djoudi


You have to escape the Ampersand (&) character with the ^ character in every occurrence of it.

start https://www.google.dz/?gws_rd=cr,ssl^&ei=rXc_WYq3Msy2abGXpugH#safe=off^&q=hello+world
like image 21
jgmh Avatar answered Oct 20 '22 03:10

jgmh