I think I understand what you mean. I made a solution in PHP, but you can use the same logic in another language. These /../
mean that the URL is shortened, and the removed content is where the dots are. Example:
http://um-site-qualquer.com/categorias/tecnologia/titulo-da-pagina
Could be shortened to http://um-site-qualquer.com/../titulo-da-pagina. This reduces the size of the "phrase" but still keeps the original address by clicking on it. It is possible to reproduce the same effect.
I created a regular expression that takes the content between the first bar and the last URL bar (/../
). After that I simply used the preg_match_all
to get the REGEX result and create a new variable with the new address. With both addresses in hand (the original and the shortened), we can create a tag <a>
the way you want it. See the code:
<?php
// URL de exemplo
$url = "http://www.exemplo.com/categorias/jogos/veja-as-incriveis-novidades-de-2015";
// Aplica o Regex na URL
preg_match_all('/[\da-z\.-]+\/(.+)\//', $url, $url_match);
// Pega o resultado do Regex
$new_url = str_replace($url_match[1][0], "..", $url);
// Cria um elemento <a> com nossas URLs.
$element = "<a href='$url'>$new_url</a>";
// Imprime o resultado na página
echo $element;
See it working on Ideone: https://ideone.com/NEV6j6
On a page running PHP, the result will be this (notice that when you click on the link the original address that opens):
<a href='http://www.exemplo.com/categorias/jogos/veja-as-incriveis-novidades-de-2015'>http://www.exemplo.com/../veja-as-incriveis-novidades-de-2015</a>
You’re confused. After all, do you want to know how to generate links or how the browser status bar works? In Google Chrome, the links are displayed briefly and after a few seconds the full link is displayed in the status bar.. is just a visual feature of the browser, nothing to do with php, javascript, etc..
– Daniel Omine
The browser just hides the core of the URL, leaving the domain and the end. When you hold the pointer over the link it appears whole. You can switch to advanced browser options.
– Papa Charlie
I’ve seen this before and it’s nothing you guys talked about. And I know it’s related to Back-end, but I only know php so it’s no use if I don’t tag and receive the response in java. I will consider the answer useless. And it makes no sense to HIDE because facebook has GIGANTIC links and it doesn’t happen.
– Asura Khan
canto inferior esquerdo do chrome o link
you’re talking about how the browser shows the URL. This appears on your website?– Papa Charlie
No, I’m talking about the /.../ that turns into /category/ usually I see turn into category, but I’ve also seen it turn into /321312/ probably ID or code of something. And it’s not a browser thing, I’m sure. It’s probably a Json, because it’s something "variable" .
– Asura Khan
Didn’t realize it only happens with large links?
– Papa Charlie
@Asurakhan I am closing the question for lack of clarity. Notice that you have received three answers already, and each speaks of a different thing. It is clear that people are not understanding what you want exactly. Could you clarify, preferably by editing the question? If you need any clarification from me, just call me with
@bfavaretto
here in the comments.– bfavaretto
/../
not if transforms for/321312/
. What happens is that in some systems the path can be reduced to/../
for viewing only, but inhref
,src
, etc. the path continues complete.– Oeslei