Rick Joe Rick Joe - 1 year ago 72
HTML Question

search/./page the dot is disappearing - html

I have a search in my page, like this:

<a href=/search/./1>First page</a>

- I'm searching for

What is happening is, the
is disappearing in the URL.

Place your mouse over the link in the snippet to see the problem.

What is causing this?

How to solve it if an user searches for

Answer Source

This happens, because in file systems the . character represents the current folder, so

mypage.com/search/. == mypage.com/search/

The browsers know this, and they automatically strip the dot.

If I understand well, you would like to make your search SEO friendly.

You can do something like this:

Base64 encode the dot, and prepend it with some custom characters, which can tell your search code that this is base64 encoded.

If you have regular searches (no dot, but some meaningful expression), you leave it as it is.

For example:

Meaningful expression: some product

<a href="mysite.com/search/some%20product/1"`>First page</a>

some%20product is the urlencoded version of some product.

It is recommended to urlencode your search expression, to make it safer (so it works with any browser/server).


<a href="mysite.com/search/B64E|Lg==/1">First page</a>

Where: Lg== is the base64 encoded .

In the case of base64 encoded stuff, you don't urlencode anything.

And in your search code, you can check for the existence of B64E| in the parameter, and if it exists, split your parameter on | and base64 decode the second element of the split result.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download