URL: Username with @

2020-01-23 16:46发布

To send username and password with a URL, we use this scheme:

http://username:password@www.my_site.com

But my username is my_email@gmail.com.
The problem is the @.

How can I solve it?

3条回答
地球回转人心会变
2楼-- · 2020-01-23 17:21

Use %40 in your username instead of the @ symbol for the url encoding. It should pass it properly then.

查看更多
Luminary・发光体
3楼-- · 2020-01-23 17:37

You need to URL encode the @ as %40.

查看更多
\"骚年 ilove
4楼-- · 2020-01-23 17:39

Just do:

 http://my_email%40gmail.com:password@www.my_site.com

I am quite surprised that problem was with username @ and not the password -usually this is where I get reserved characters in url authority or path parts.

To solve general case of special characters: Just open chrome console with F12 then paste encodeURIComponent(str) where str is your password (or username) and then use the encoded result to form url with password.

Hope this saves you some time.

查看更多
登录 后发表回答