2
How to make all site urls shortened by hiding all directory paths?
For example:
www.meusite.com/models/scripts/arquivo.php
www.meusite.com/view/templates/arquivo.php
www.meusite.com/view/templates/especifica/arquivo.php
And I want you to stay forever:
www.meusite.com/arquivo.php
Is that possible? How to do it? (already in advance I read all, or almost all the main questions about it here on the site and did not find an objective answer).
Update: What I’m looking for is a rule with regular expression that always does this, in all urls, in the answer line and comments of the @Miguel Neto response.
In this case I believe, that you would have to put your files at the root of your project.
– Marconi
@Marconi I think I expressed myself badly. In case I have a url
https://www.meusite.com.br/pasta1/pasta2/pasta3/arquivo.php
for example, and I want it to appear on the navigation bar onlyhttps://www.meusite.com.br/arquivo.php
. This is not possible with htaccess?– gustavox
In the case of the answer below, you can use a regex that reaches the expected result.
– Miguel Neto
Unless you specify the path to each file on
.htaccess
, or create file name patterns such aslib_arquivo.php
that will redirect tolib/arquivo.php
cannot be done only with regex. Unfortunately, this is not possible due to lack of information. There is no way to recover the folder of a particular file from a URL without having it mapped. Another alternative is to use a language and implement Friendly URL.– marcusagm
Because it is @marcusagm actually I was making a mess to structure the folders and files of my project... so the solution was to change the structure of the folders and put these files in the same root, and then I no longer need to hide the paths... I think this comment of yours is actually an answer, because it solves my question ("Is it possible?"). Cheer up put there as an answer so I can close the topic. Thanks.
– gustavox
As it is imagined, because the path that was trying to do without specifying by htaccess file by file, would result in the reverse path, the URL presenting the folder but the file was at the root rs
– marcusagm