What Does "Invalid Characters in URL" Mean?

Some characters should not be used in URLs. Generally speaking, it's best practice to only use the following characters in a URL:

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=

Any other characters in the URL could cause problems with browsers, web applications, or search engines.

Why It's Important

These special characters can sometimes cause unexpected issues and are best avoided if possible. Keep in mind, special character sets may not be able to be typed or displayed correctly by all visitors. Using only the safe character set will ensure everyone is able to access your content.

How To Fix

Any character not in the list above can still be used in the URL, but it must be percent-encoded first. This is a method of representing characters using the percent sign followed by two hexadecimal digits. For example, the grave accent character ` is represented as %60 when it is percent-encoded. So instead of

http://www.example.com/grave`accent

the URL should be

http://www.example.com/grave%60accent

Likewise, the URL

www.example.com/中文/北京[city]

would be better to be encoded to be represented as

http://www.example.com/%E4%B8%AD%E6%96%87%/E5%8C%97%E4%BA%AC%5Bcity%5D

You can use special functions to do the encoding for you, or you can refer to a table for commonly-used characters' encoding values.

Reserved Characters

A related issue is the use of "reserved" characters. These characters are valid to use in URLs, but they serve a specific technical purpose. For example, the forward slash character "/" indicates a subdirectory, while a semicolon ":" is used to separate the URL from a port number. Therefore, if you intend to use these characters for purposes other than their reserved function, you will need to encode them.

The following characters are reserved for special use:

:/#?&@%+~

While Dragon Metrics will not be able to identify whether or not you intended to use these characters for their actual function, you may consider using Dragon Metrics' Site Explorer feature to search for these characters in the URL to check for any potential issues.

Did this answer your question?